From 733508d07ff918786da4183636a05fb7a95add42 Mon Sep 17 00:00:00 2001 From: Bruce Pennypacker Date: Tue, 22 Apr 2014 18:44:41 +0000 Subject: [PATCH 1/2] Changed behavior of deregister. If an instance is not found in the ELB then simply return 'changed=false'. Otherwise always remove the instance from the ELB no matter what state its currently in. --- cloud/ec2_elb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cloud/ec2_elb b/cloud/ec2_elb index e76816fbca3..e36a71e1ba0 100644 --- a/cloud/ec2_elb +++ b/cloud/ec2_elb @@ -129,18 +129,20 @@ class ElbManager: for lb in self.lbs: initial_state = self._get_instance_health(lb) if wait else None - - if initial_state and initial_state.state == 'InService': - lb.deregister_instances([self.instance_id]) - else: + if initial_state is None: + # The instance isn't registered with this ELB so just + # return unchanged return + lb.deregister_instances([self.instance_id]) + + # The ELB is changing state in some way. Either an instance that's + # InService is moving to OutOfService, or an instance that's + # already OutOfService is being deregistered. + self.changed = True + if wait: self._await_elb_instance_state(lb, 'OutOfService', initial_state, timeout) - else: - # We cannot assume no change was made if we don't wait - # to find out - self.changed = True def register(self, wait, enable_availability_zone, timeout): """Register the instance for all ELBs and wait for the ELB From 8baeccacab9d33621e19a8b25cd4ad7c3aca68be Mon Sep 17 00:00:00 2001 From: Bruce Pennypacker Date: Thu, 24 Apr 2014 20:41:51 +0000 Subject: [PATCH 2/2] removed unwanted 'if wait else None' --- cloud/ec2_elb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/ec2_elb b/cloud/ec2_elb index e36a71e1ba0..228048d3814 100644 --- a/cloud/ec2_elb +++ b/cloud/ec2_elb @@ -128,7 +128,7 @@ class ElbManager: to report it out-of-service""" for lb in self.lbs: - initial_state = self._get_instance_health(lb) if wait else None + initial_state = self._get_instance_health(lb) if initial_state is None: # The instance isn't registered with this ELB so just # return unchanged