ELBs can now be deleted before their autoscaling groups.
Also, fix name clash in autoscaling tests.
This commit is contained in:
parent
076a6a7055
commit
a330b1d346
@ -197,17 +197,10 @@ class FakeAutoScalingGroup(object):
|
|||||||
backend.delete_autoscaling_group(resource_name)
|
backend.delete_autoscaling_group(resource_name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
except LoadBalancerNotFoundError:
|
|
||||||
# sometimes the ELB gets modified before the ASG, so just skip over desired capacity
|
|
||||||
backend.autoscaling_groups.pop(resource_name, None)
|
|
||||||
|
|
||||||
def delete(self, region_name):
|
def delete(self, region_name):
|
||||||
backend = autoscaling_backends[region_name]
|
backend = autoscaling_backends[region_name]
|
||||||
try:
|
backend.delete_autoscaling_group(self.name)
|
||||||
backend.delete_autoscaling_group(self.name)
|
|
||||||
except LoadBalancerNotFoundError:
|
|
||||||
# sometimes the ELB gets deleted before the ASG, so just skip over desired capacity
|
|
||||||
backend.autoscaling_groups.pop(self.name, None)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def physical_resource_id(self):
|
def physical_resource_id(self):
|
||||||
@ -435,7 +428,14 @@ class AutoScalingBackend(BaseBackend):
|
|||||||
def update_attached_elbs(self, group_name):
|
def update_attached_elbs(self, group_name):
|
||||||
group = self.autoscaling_groups[group_name]
|
group = self.autoscaling_groups[group_name]
|
||||||
group_instance_ids = set(state.instance.id for state in group.instance_states)
|
group_instance_ids = set(state.instance.id for state in group.instance_states)
|
||||||
for elb in self.elb_backend.describe_load_balancers(names=group.load_balancers):
|
|
||||||
|
try:
|
||||||
|
elbs = self.elb_backend.describe_load_balancers(names=group.load_balancers)
|
||||||
|
except LoadBalancerNotFoundError:
|
||||||
|
# ELBs can be deleted before their autoscaling group
|
||||||
|
return
|
||||||
|
|
||||||
|
for elb in elbs:
|
||||||
elb_instace_ids = set(elb.instance_ids)
|
elb_instace_ids = set(elb.instance_ids)
|
||||||
self.elb_backend.register_instances(elb.name, group_instance_ids - elb_instace_ids)
|
self.elb_backend.register_instances(elb.name, group_instance_ids - elb_instace_ids)
|
||||||
self.elb_backend.deregister_instances(elb.name, elb_instace_ids - group_instance_ids)
|
self.elb_backend.deregister_instances(elb.name, elb_instace_ids - group_instance_ids)
|
||||||
|
@ -386,7 +386,7 @@ Boto3
|
|||||||
|
|
||||||
|
|
||||||
@mock_autoscaling
|
@mock_autoscaling
|
||||||
def test_create_autoscaling_group():
|
def test_create_autoscaling_group_boto3():
|
||||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||||
_ = client.create_launch_configuration(
|
_ = client.create_launch_configuration(
|
||||||
LaunchConfigurationName='test_launch_configuration'
|
LaunchConfigurationName='test_launch_configuration'
|
||||||
@ -402,7 +402,7 @@ def test_create_autoscaling_group():
|
|||||||
|
|
||||||
|
|
||||||
@mock_autoscaling
|
@mock_autoscaling
|
||||||
def test_describe_autoscaling_groups():
|
def test_describe_autoscaling_groups_boto3():
|
||||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||||
_ = client.create_launch_configuration(
|
_ = client.create_launch_configuration(
|
||||||
LaunchConfigurationName='test_launch_configuration'
|
LaunchConfigurationName='test_launch_configuration'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user