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

Add retries on the same failures as AWSRetry for the waiters #185

Merged
merged 3 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/185-waiter-retry-failures.yml
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 25 additions & 4 deletions plugins/module_utils/waiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)


Expand Down