From 23f06500c3571ad6bc74cc54b5a39088bc9ec0aa Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Thu, 29 Oct 2020 20:03:55 +0100 Subject: [PATCH 1/3] Add retries on the same failures as AWSRetry for the waiters --- plugins/module_utils/waiters.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/plugins/module_utils/waiters.py b/plugins/module_utils/waiters.py index 9e8ff54cde6..f81117fceb8 100644 --- a/plugins/module_utils/waiters.py +++ b/plugins/module_utils/waiters.py @@ -4,6 +4,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import copy + try: import botocore.waiter as core_waiter except ImportError: @@ -297,23 +299,42 @@ } +def _inject_limit_retries(model): + + extra_retries = [ + 'RequestLimitExceeded', 'Unavailable', 'ServiceUnavailable', + 'InternalFailure', 'InternalError', 'TooManyRequestsException', + 'Throttling'] + + acceptors = [] + for error in extra_retries: + acceptors.append({"state": "success", "matcher": "error", "expected": error}) + + _model = copy.deepcopy(model) + + for waiter in model["waiters"]: + _model["waiters"][waiter]["acceptors"].extend(acceptors) + + return _model + + def ec2_model(name): - ec2_models = core_waiter.WaiterModel(waiter_config=ec2_data) + ec2_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(ec2_data)) return ec2_models.get_waiter(name) def waf_model(name): - waf_models = core_waiter.WaiterModel(waiter_config=waf_data) + waf_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(waf_data)) return waf_models.get_waiter(name) def eks_model(name): - eks_models = core_waiter.WaiterModel(waiter_config=eks_data) + eks_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(eks_data)) return eks_models.get_waiter(name) def rds_model(name): - rds_models = core_waiter.WaiterModel(waiter_config=rds_data) + rds_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(rds_data)) return rds_models.get_waiter(name) From 51da5b110011b86784af4e4019c2714e1a991e96 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 7 Nov 2020 19:41:41 +0100 Subject: [PATCH 2/3] Add changelog --- changelogs/fragments/185-waiter-retry-failures.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/185-waiter-retry-failures.yml diff --git a/changelogs/fragments/185-waiter-retry-failures.yml b/changelogs/fragments/185-waiter-retry-failures.yml new file mode 100644 index 00000000000..a9dc8560dd1 --- /dev/null +++ b/changelogs/fragments/185-waiter-retry-failures.yml @@ -0,0 +1,2 @@ +minor_changes: +- module_utils/waiters - Add retries to our waiters for the same failure codes that we retry with AWSRetry (https://github.com/ansible-collections/amazon.aws/pull/185) From 87b6acc67ceb195376e37191f51d11b9204adaad Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Sat, 7 Nov 2020 22:38:07 +0100 Subject: [PATCH 3/3] ci_complete