{"action":"created","issue":{"url":"https://api.github.com/repos/boto/boto/issues/2576","labels_url":"https://api.github.com/repos/boto/boto/issues/2576/labels{/name}","comments_url":"https://api.github.com/repos/boto/boto/issues/2576/comments","events_url":"https://api.github.com/repos/boto/boto/issues/2576/events","html_url":"https://github.com/boto/boto/issues/2576","id":41456767,"number":2576,"title":"boto.ec2.elb.loadbalancer.LoadBalancer deregister_instances returns Inconsistent Response","user":{"login":"colinbjohnson","id":1594843,"avatar_url":"https://avatars.githubusercontent.com/u/1594843?v=3","gravatar_id":"","url":"https://api.github.com/users/colinbjohnson","html_url":"https://github.com/colinbjohnson","followers_url":"https://api.github.com/users/colinbjohnson/followers","following_url":"https://api.github.com/users/colinbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/colinbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/colinbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinbjohnson/subscriptions","organizations_url":"https://api.github.com/users/colinbjohnson/orgs","repos_url":"https://api.github.com/users/colinbjohnson/repos","events_url":"https://api.github.com/users/colinbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/colinbjohnson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/boto/boto/labels/EC2","name":"EC2","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-08-28T23:22:59Z","updated_at":"2015-01-02T18:20:30Z","closed_at":null,"body":"## Issue Statement:\r\nThe ```deregister_instances``` method of Boto returns an inconsistent response, depending on the following condition:\r\n\r\n1. if the instance has never registered with a given ELB\r\n2. if the instance has been registered with and then deregistered from a given ELB\r\n\r\n## Issue Reproduction:\r\n1. Create an ELB\r\n2. Create an EC2 instance\r\n3. Run the following:\r\n```\r\n#!/usr/bin/env python\r\n\r\nimport logging\r\n\r\nimport boto\r\nimport boto.ec2\r\nimport boto.ec2.elb\r\n\r\nlog = logging.getLogger(__name__)\r\nlogging.basicConfig(level=logging.DEBUG)\r\nlogging.getLogger('boto').setLevel(logging.DEBUG)\r\n\r\nelb_name = 'test'\r\ninstances = 'i-d415b8f9'\r\nregion = 'us-east-1'\r\n\r\nconn = boto.ec2.elb.connect_to_region(region)\r\n\r\nload_balancer = conn.get_all_load_balancers(elb_name)[0]\r\nderegister_result = load_balancer.deregister_instances(instances)\r\n```\r\n\r\n### Result When Registered when and Deregistered from an ELB:\r\n```\r\nDEBUG:boto:Method: GET\r\nDEBUG:boto:Path: /\r\nDEBUG:boto:Data: \r\nDEBUG:boto:Headers: {}\r\nDEBUG:boto:Host: elasticloadbalancing.us-east-1.amazonaws.com\r\nDEBUG:boto:Port: 443\r\nDEBUG:boto:Params: {'Action': 'DeregisterInstancesFromLoadBalancer', 'Version': '2012-06-01', 'Instances.member.1.InstanceId': 'i-8314b9ae', 'LoadBalancerName': u'test'}\r\nDEBUG:boto:Token: None\r\nDEBUG:boto:using _calc_signature_2\r\nDEBUG:boto:query string: AWSAccessKeyId=AKIAIODMXT7SIYL3CQFA&Action=DeregisterInstancesFromLoadBalancer&Instances.member.1.InstanceId=i-8314b9ae&LoadBalancerName=test&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-08-28T23%3A10%3A13Z&Version=2012-06-01\r\nDEBUG:boto:string_to_sign: GET\r\nelasticloadbalancing.us-east-1.amazonaws.com\r\n/\r\nAWSAccessKeyId=AKIAIODMXT7SIYL3CQFA&Action=DeregisterInstancesFromLoadBalancer&Instances.member.1.InstanceId=i-8314b9ae&LoadBalancerName=test&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-08-28T23%3A10%3A13Z&Version=2012-06-01\r\nDEBUG:boto:len(b64)=44\r\nDEBUG:boto:base64 encoded digest: V/bLLgFG3HhbFgurzYxfib/1DUSRMXYDSxD9JqsbjbA=\r\nDEBUG:boto:query_string: AWSAccessKeyId=AKIAIODMXT7SIYL3CQFA&Action=DeregisterInstancesFromLoadBalancer&Instances.member.1.InstanceId=i-8314b9ae&LoadBalancerName=test&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-08-28T23%3A10%3A13Z&Version=2012-06-01 Signature: V/bLLgFG3HhbFgurzYxfib/1DUSRMXYDSxD9JqsbjbA=\r\nDEBUG:boto:Final headers: {'Content-Length': 0, 'Host': u'elasticloadbalancing.us-east-1.amazonaws.com', 'User-Agent': 'Boto/2.32.1 Python/2.7.5 Darwin/13.3.0'}\r\nDEBUG:boto:Response headers: [('x-amzn-requestid', '77417643-2f08-11e4-9b9e-fdc8d954a703'), ('date', 'Thu, 28 Aug 2014 23:10:13 GMT'), ('content-length', '376'), ('content-type', 'text/xml')]\r\nDEBUG:boto:<DeregisterInstancesFromLoadBalancerResponse xmlns=\"http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/\">\r\n  <DeregisterInstancesFromLoadBalancerResult>\r\n    <Instances/>\r\n  </DeregisterInstancesFromLoadBalancerResult>\r\n  <ResponseMetadata>\r\n    <RequestId>77417643-2f08-11e4-9b9e-fdc8d954a703</RequestId>\r\n  </ResponseMetadata>\r\n</DeregisterInstancesFromLoadBalancerResponse>\r\n```\r\n### Result When Never Having Been Registered with an ELB:\r\n```\r\nDEBUG:boto:Method: GET\r\nDEBUG:boto:Path: /\r\nDEBUG:boto:Data: \r\nDEBUG:boto:Headers: {}\r\nDEBUG:boto:Host: elasticloadbalancing.us-east-1.amazonaws.com\r\nDEBUG:boto:Port: 443\r\nDEBUG:boto:Params: {'Action': 'DeregisterInstancesFromLoadBalancer', 'Version': '2012-06-01', 'Instances.member.1.InstanceId': 'i-8314b9ae', 'LoadBalancerName': u'test'}\r\nDEBUG:boto:Token: None\r\nDEBUG:boto:using _calc_signature_2\r\nDEBUG:boto:query string: AWSAccessKeyId=AKIAIODMXT7SIYL3CQFA&Action=DeregisterInstancesFromLoadBalancer&Instances.member.1.InstanceId=i-8314b9ae&LoadBalancerName=test&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-08-28T23%3A07%3A49Z&Version=2012-06-01\r\nDEBUG:boto:string_to_sign: GET\r\nelasticloadbalancing.us-east-1.amazonaws.com\r\n/\r\nAWSAccessKeyId=AKIAIODMXT7SIYL3CQFA&Action=DeregisterInstancesFromLoadBalancer&Instances.member.1.InstanceId=i-8314b9ae&LoadBalancerName=test&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-08-28T23%3A07%3A49Z&Version=2012-06-01\r\nDEBUG:boto:len(b64)=44\r\nDEBUG:boto:base64 encoded digest: Y/NZ/u/M4Ll2/oIRWDQjthUtOHUViKdBxptJ3uYlyPI=\r\nDEBUG:boto:query_string: AWSAccessKeyId=AKIAIODMXT7SIYL3CQFA&Action=DeregisterInstancesFromLoadBalancer&Instances.member.1.InstanceId=i-8314b9ae&LoadBalancerName=test&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-08-28T23%3A07%3A49Z&Version=2012-06-01 Signature: Y/NZ/u/M4Ll2/oIRWDQjthUtOHUViKdBxptJ3uYlyPI=\r\nDEBUG:boto:Final headers: {'Content-Length': 0, 'Host': u'elasticloadbalancing.us-east-1.amazonaws.com', 'User-Agent': 'Boto/2.32.1 Python/2.7.5 Darwin/13.3.0'}\r\nDEBUG:boto:Response headers: [('x-amzn-requestid', '219bcd17-2f08-11e4-930a-1f3534f57fb1'), ('date', 'Thu, 28 Aug 2014 23:07:48 GMT'), ('content-length', '302'), ('content-type', 'text/xml'), ('nncoection', 'close')]\r\nDEBUG:boto:<ErrorResponse xmlns=\"http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/\">\r\n  <Error>\r\n    <Type>Sender</Type>\r\n    <Code>InvalidInstance</Code>\r\n    <Message>Could not find EC2 instance i-8314b9ae.</Message>\r\n  </Error>\r\n  <RequestId>219bcd17-2f08-11e4-930a-1f3534f57fb1</RequestId>\r\n</ErrorResponse>\r\n\r\nERROR:boto:400 Bad Request\r\nERROR:boto:<ErrorResponse xmlns=\"http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/\">\r\n  <Error>\r\n    <Type>Sender</Type>\r\n    <Code>InvalidInstance</Code>\r\n    <Message>Could not find EC2 instance i-8314b9ae.</Message>\r\n  </Error>\r\n  <RequestId>219bcd17-2f08-11e4-930a-1f3534f57fb1</RequestId>\r\n</ErrorResponse>\r\n\r\nTraceback (most recent call last):\r\n  File \"boto_deregister_test.py\", line 28, in <module>\r\n    deregister_result = load_balancer.deregister_instances(instances)\r\n  File \"/Library/Python/2.7/site-packages/boto/ec2/elb/loadbalancer.py\", line 291, in deregister_instances\r\n    instances)\r\n  File \"/Library/Python/2.7/site-packages/boto/ec2/elb/__init__.py\", line 524, in deregister_instances\r\n    params, [('member', InstanceInfo)])\r\n  File \"/Library/Python/2.7/site-packages/boto/connection.py\", line 1166, in get_list\r\n    raise self.ResponseError(response.status, response.reason, body)\r\nboto.exception.BotoServerError: BotoServerError: 400 Bad Request\r\n<ErrorResponse xmlns=\"http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/\">\r\n  <Error>\r\n    <Type>Sender</Type>\r\n    <Code>InvalidInstance</Code>\r\n    <Message>Could not find EC2 instance i-8314b9ae.</Message>\r\n  </Error>\r\n  <RequestId>219bcd17-2f08-11e4-930a-1f3534f57fb1</RequestId>\r\n</ErrorResponse>\r\n```"},"comment":{"url":"https://api.github.com/repos/boto/boto/issues/comments/68548526","html_url":"https://github.com/boto/boto/issues/2576#issuecomment-68548526","issue_url":"https://api.github.com/repos/boto/boto/issues/2576","id":68548526,"user":{"login":"jonathanwcrane","id":6143363,"avatar_url":"https://avatars.githubusercontent.com/u/6143363?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanwcrane","html_url":"https://github.com/jonathanwcrane","followers_url":"https://api.github.com/users/jonathanwcrane/followers","following_url":"https://api.github.com/users/jonathanwcrane/following{/other_user}","gists_url":"https://api.github.com/users/jonathanwcrane/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanwcrane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanwcrane/subscriptions","organizations_url":"https://api.github.com/users/jonathanwcrane/orgs","repos_url":"https://api.github.com/users/jonathanwcrane/repos","events_url":"https://api.github.com/users/jonathanwcrane/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanwcrane/received_events","type":"User","site_admin":false},"created_at":"2015-01-02T18:20:30Z","updated_at":"2015-01-02T18:20:30Z","body":"I think maybe the documentation should be changed.  According to http://boto.readthedocs.org/en/latest/ref/elb.html, deregister_instances() returns \"An updated list of instances for this Load Balancer\"\r\n\r\nThat statement is clearly not always true.   When I perform an operations that gets the ELB down to zero instances, the return value is a list of two non-existent instances.  In this case, the return result should be the empty list, according to the docs.  So chance the docs.  :)"}}