-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
check elb type in compare_subnets for elbv2 #50203
check elb type in compare_subnets for elbv2 #50203
Conversation
Someone might want to add |
ready_for_review |
Hello @ezmac ! I wrote that part of the code in elbv2.py that does the comparison. Although I wrote it with NLB in mind, it was tested and has worked with ALB as well. In our own environment, we've quite suddenly been having the missing key problem, even with NLBs that don't have a static IP. This previously, absolutely, worked, because the key was always present, with an array containing an empty dict. Something has changed, either in boto or in the AWS API return, that's excluding the "empty" entry. I think it may be the API, based on the fact that this seems to have affected different people at different times, and though I may have missed it I don't see anything in the boto project that would have cleared this key out. To that end, the code in your PR will "fix" ALBs but will still cause NLBs with no static IP to fail. I recommend removing the conditional about ELB type and replacing it with this smaller fix instead. From the original file's line 172, which was this: for address in subnet['LoadBalancerAddresses']: Change it to this: for address in subnet.get('LoadBalancerAddresses', []): So far this is working well in my local environment. I could create a separate PR if you want but it may be easier for you to just make the change here. |
@ezmac This PR contains |
601fdf2
to
cfc5289
Compare
Thanks for the input; your solution is cleaner and looks like it still works for me. |
Thanks for the quick update @ezmac ! |
shipit |
Thanks @ezmac for the fix, @briantist for the improvements and @flowerysong for the review. |
SUMMARY
Fixes #49558
Add a check for LB type before accessing property that may not be there.
NLB and ALB have different structures for AvailabilityZone property
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elbv2.html#ElasticLoadBalancingv2.Client.create_load_balancer
For NLB:
For ALB
ISSUE TYPE
COMPONENT NAME
elbv2.py