-
Notifications
You must be signed in to change notification settings - Fork 397
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
ec2_vpc_nat_gateway cleanup #445
ec2_vpc_nat_gateway cleanup #445
Conversation
Test failures look to be due to a lack of retry decorators on ec2_vpc_nat_gateway_info |
In the strictest sense it can be its own PR, which I'd happily review and merge pretty quickly. In the past I've bundled the and _info cleanup together in a couple of cases, because the tests tend to be linked (and getting reviews was difficult before yourself and the other new cloud team members started). |
8126d8b
to
3741139
Compare
@tremble Ok, I will do it in a while and I will ping you then. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress here
return True, '' | ||
|
||
ip_released = False | ||
try: | ||
client.describe_addresses(aws_retry=True, AllocationIds=[allocation_id]) | ||
except botocore.exceptions.ClientError as e: | ||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a more specific failure that we could catch here with is_boto3_error_code (probably InvalidAllocationID.NotFound, not sure about any others) to do the return True, str(e)
, and handle general exceptions separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jillr Thank you for reviewing. I tried to add the catch on this error. Let me know if it makes sense to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jillr I noticed adding the explicit catch of the InvalidAllocationID.NotFound
error implies removing the botocore.exceptions.ClientError
because InvalidAllocationID.NotFound
is already catched by ClientError
. Otherwise, I can catch only InvalidAllocationID.NotFound
and then consider the except botocore.exceptions.BotoCoreError
(this is what I've actually done right now). Let me know if this works for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to catch both BotoCoreError and ClientError.
While pylint thinks that except is_boto3_error_code('InvalidAllocationID.NotFound')
catches all ClientError, this is actually incorrect and due to a bug in pylint. pylint-dev/pylint#2174
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tremble Ok, my Shippable check was failing due to this duplicate catch. I added again the the botocore.exceptions.ClientError
. Thanks.
ebf852c
to
2c00a76
Compare
0eba859
to
79ce47f
Compare
# IP address likely already released | ||
# Happens with gateway in 'deleted' state that | ||
# still lists associations | ||
return True, str(e) | ||
return True, e | ||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: | |
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I forget to commit it. Could you kindly have a look as well at this #436 (when you will have some time)?
6dc30db
to
f98c541
Compare
@alinabuzachis this PR contains the following merge commits: Please rebase your branch to remove these commits. |
edec340
to
923f544
Compare
2e1a7e6
to
38f3b66
Compare
* use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple small things here, thanks @alinabuzachis for all your work on this
"EIP {0} does not exist".format(eip_address) | ||
) | ||
except is_boto3_error_code('InvalidAddress.Malformed') as e: | ||
allocation_id = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the EIP the user provides is malformed we should probably return that information to the user so that they can troubleshoot their playbook, we're returning an empty msg
now. For a malformed EIP we should probably fail here rather than returning back to pre_create since we can't proceed with the information provided in the playbook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added fail_json for this case. Let me know if this works for you. Thank you @jillr.
except is_boto3_error_code('InvalidAddress.Malformed') as e: | ||
allocation_id = None | ||
except is_boto3_error_code('InvalidAddress.NotFound') as e: # pylint: disable=duplicate-except | ||
allocation_id = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably also want to exit here as well and return the error to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing @jillr. I added the specific msg for this case. As allocation_id will be None, it will exit propagating the message. https://github.com/ansible-collections/community.aws/pull/445/files#diff-847118175f7fbd015daf612a3319157ca22874f706c01f26348f4f86f67384d9R742-R749 Is this working for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this makes sense to me. Thanks!
Signed-off-by: Alina Buzachis <[email protected]>
38f3b66
to
c555d66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* ec2_vpc_nat_gateway overall cleanup * use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]>
* ec2_vpc_nat_gateway overall cleanup * use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections@9b60a2d
* ec2_vpc_nat_gateway overall cleanup * use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]>
* ec2_vpc_nat_gateway overall cleanup * use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]>
* ec2_vpc_nat_gateway overall cleanup * use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]>
* Add waiter for ec2_vpc_nat_gateway (ansible-collections#445) * Added NatGatewayAvailable waiter Signed-off-by: Alina Buzachis <[email protected]>
* ec2_vpc_nat_gateway overall cleanup * use custm waiters to manage NAT gateway states (deleted and available) * imporve error handling * improve documentation examples * code cleaning Signed-off-by: Alina Buzachis <[email protected]> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections@9b60a2d
SUMMARY
Cleanup ec2_vpc_nat_gateway
ISSUE TYPE
COMPONENT NAME
ec2_vpc_nat_gateway