Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_all_groups returns invalid objects when any ASG is attached to a target group #3613

Open
tangentspace opened this issue Sep 21, 2016 · 10 comments

Comments

@tangentspace
Copy link

We recently started using Application Load Balancers, and many legacy Python scripts that still use boto 2.x started failing. Any ASG that's attached to a target group results in a malformed object coming back from the get_all_groups function, here is the __dict__ attribute from one such object (note the many missing values such as min_size, name, and desired_capacity):

{'autoscaling_group_arn': u'arn:aws:autoscaling:us-west-2:012345678910:autoScalingGroup:b72815ad-fafa-42e5-9f66-9d6bd4608a1c:autoScalingGroupName/devops-develop-jenkins-ng',
'availability_zones': [u'us-west-2a', u'us-west-2b', u'us-west-2c'],
'connection': AutoScaleConnection:autoscaling.us-west-2.amazonaws.com,
'created_time': None,
'default_cooldown': 300,
'desired_capacity': None,
'enabled_metrics': [],
'health_check_period': None,
'health_check_type': u'EC2',
'instance_id': None,
'instances': [Instance<id:i-af752bb7, state:InService, health:Healthy>],
'launch_config_name': None,
'load_balancers': [],
'max_size': 2,
'member': u'arn:aws:elasticloadbalancing:us-west-2:012345678910:targetgroup/devops-develop-jenkins-ng/74eda25cc67b618d',
'min_size': None,
'name': None,
'placement_group': None,
'tags': None,
'termination_policies': [u'Default'],
'vpc_zone_identifier': None}

It looks like boto has not been updated to handle a non-empty TargetGroupARNs element in the XML response (

def startElement(self, name, attrs, connection):
if name == 'Instances':
self.instances = ResultSet([('member', Instance)])
return self.instances
elif name == 'LoadBalancerNames':
return self.load_balancers
elif name == 'AvailabilityZones':
return self.availability_zones
elif name == 'EnabledMetrics':
self.enabled_metrics = ResultSet([('member', EnabledMetric)])
return self.enabled_metrics
elif name == 'SuspendedProcesses':
self.suspended_processes = ResultSet([('member', SuspendedProcess)])
return self.suspended_processes
elif name == 'Tags':
self.tags = ResultSet([('member', Tag)])
return self.tags
elif name == 'TerminationPolicies':
return self.termination_policies
else:
return
def endElement(self, name, value, connection):
if name == 'MinSize':
self.min_size = int(value)
elif name == 'AutoScalingGroupARN':
self.autoscaling_group_arn = value
elif name == 'CreatedTime':
self.created_time = value
elif name == 'DefaultCooldown':
self.default_cooldown = int(value)
elif name == 'LaunchConfigurationName':
self.launch_config_name = value
elif name == 'DesiredCapacity':
self.desired_capacity = int(value)
elif name == 'MaxSize':
self.max_size = int(value)
elif name == 'AutoScalingGroupName':
self.name = value
elif name == 'PlacementGroup':
self.placement_group = value
elif name == 'HealthCheckGracePeriod':
try:
self.health_check_period = int(value)
except ValueError:
self.health_check_period = None
elif name == 'HealthCheckType':
self.health_check_type = value
elif name == 'VPCZoneIdentifier':
self.vpc_zone_identifier = value
elif name == 'InstanceId':
self.instance_id = value
else:
setattr(self, name, value)
)

@RomekRJM
Copy link

I've also encountered that problem, I'm about to post the merge request with the fix.

@RomekRJM
Copy link

Done: #3616 . I've also added some tests, hopefuly it's going to be merged soon.

@shaharmor
Copy link

Any chance to get this fixed?

@RomekRJM
Copy link

RomekRJM commented Nov 8, 2016

@shaharmor I've sent that pull request 6w ago and no one picked it, Looking at 344 other unmerged patches, I'm fairly sure it's not going to be done soon, if ever. I honestly recommend switching to boto3, v2 does not seem to be actively maintained.

@vanga
Copy link

vanga commented Feb 23, 2017

I tried to look at the code, but couldn't figure out why it was breaking if startElement function returns None.

I am just wondering, isn't the correct fix is to not make it error out when there is a new/unhandled property?

Just adding another else condition is going to only handle this particular property Target Groups, if tomorrow AWS adds one more property, will this fix break again?

I am just curious,

Thanks.

@RomekRJM
Copy link

I can imagine, that some people would actually want to make use of that particular field. Anyway, boto3 is the way to go. We've migrated our stuff to it and works like a breeze.

@SM616
Copy link

SM616 commented Dec 28, 2017

Faced with this as well while running Ansible ec2_elb module with latest version of boto. Any update on when the fix will be merged?

@locomundo
Copy link

I also ran into this issue. Is there a plan to fix it in boto2 ? I see this was filed quite a while ago...

@matisku
Copy link

matisku commented Sep 21, 2018

Any progress on that?

@jorotenev
Copy link

jorotenev commented Jun 25, 2019

Just encountered the same issue. This affects the boto_asg module of saltstack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants