From f33ca6aa1c1a54b41aff542ad1794c584f9279ec Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 1 May 2021 14:05:56 +0200 Subject: [PATCH 1/5] route53 - Fix typo in WaiterConfig --- plugins/modules/route53.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index 8cbb2647e4a..eb8842951d5 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -668,7 +668,7 @@ def main(): Id=change_resource_record_sets['ChangeInfo']['Id'], WaiterConfig=dict( Delay=WAIT_RETRY, - MaxAttemps=wait_timeout_in // WAIT_RETRY, + MaxAttempts=wait_timeout_in // WAIT_RETRY, ) ) except is_boto3_error_message('but it already exists'): From cddd928600539f8a283006cec35f318ec01a1abe Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 1 May 2021 14:09:36 +0200 Subject: [PATCH 2/5] Add retries on PriorRequestNotComplete --- plugins/modules/route53.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index eb8842951d5..7c9d88c159e 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -574,12 +574,15 @@ def main(): if (weight_in is None and region_in is None and failover_in is None) and identifier_in is not None: module.fail_json(msg="You have specified identifier which makes sense only if you specify one of: weight, region or failover.") + retry_decorator = AWSRetry.jittered_backoff( + retries=MAX_AWS_RETRIES, + delay=retry_interval_in, + catch_extra_error_codes=['PriorRequestNotComplete'], + ) + # connect to the route53 endpoint try: - route53 = module.client( - 'route53', - retry_decorator=AWSRetry.jittered_backoff(retries=MAX_AWS_RETRIES, delay=retry_interval_in) - ) + route53 = module.client('route53', retry_decorator=retry_decorator) except botocore.exceptions.HTTPClientError as e: module.fail_json_aws(e, msg='Failed to connect to AWS') From 5e41c9d8e79eb5286c3f43176dcdde03d7a86f50 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 1 May 2021 14:10:25 +0200 Subject: [PATCH 3/5] Bump max_delay for route53 retries based on retry_interval --- plugins/modules/route53.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index 7c9d88c159e..2bf956e5c60 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -578,6 +578,7 @@ def main(): retries=MAX_AWS_RETRIES, delay=retry_interval_in, catch_extra_error_codes=['PriorRequestNotComplete'], + max_delay=max(60, retry_interval_in), ) # connect to the route53 endpoint From c79e40e839ff30a4bc73faf82d766fbd2d2bd02e Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 1 May 2021 14:25:12 +0200 Subject: [PATCH 4/5] Use waiter with retrys --- plugins/modules/route53.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index 2bf956e5c60..ffbfdf4fc91 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -369,6 +369,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_message from ansible_collections.amazon.aws.plugins.module_utils.core import scrub_none_parameters from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter MAX_AWS_RETRIES = 10 # How many retries to perform when an API call is failing WAIT_RETRY = 5 # how many seconds to wait between propagation status polls @@ -667,7 +668,7 @@ def main(): ) if wait_in: - waiter = route53.get_waiter('resource_record_sets_changed') + waiter = get_waiter(route53, 'resource_record_sets_changed') waiter.wait( Id=change_resource_record_sets['ChangeInfo']['Id'], WaiterConfig=dict( From 287ca66c904ba6bc8d7c29dcb969529092cd5a6f Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 1 May 2021 14:25:21 +0200 Subject: [PATCH 5/5] changelog --- changelogs/564-route53-retries.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelogs/564-route53-retries.yml diff --git a/changelogs/564-route53-retries.yml b/changelogs/564-route53-retries.yml new file mode 100644 index 00000000000..46a99b56be2 --- /dev/null +++ b/changelogs/564-route53-retries.yml @@ -0,0 +1,6 @@ +bugfixes: +- route53 - fix typo in waiter configuration that prevented management of the delays (https://github.com/ansible-collections/community.aws/pull/564). +minor_changes: +- route53 - add retries on ``PriorRequestNotComplete`` errors (https://github.com/ansible-collections/community.aws/pull/564). +- route53 - update retry ``max_delay`` setting so that it can be set above 60 seconds (https://github.com/ansible-collections/community.aws/pull/564). +- route53 - add rate-limiting retries while waiting for changes to propagate (https://github.com/ansible-collections/community.aws/pull/564).