Skip to content

Commit

Permalink
aws_api_gateway : Switch to jittered backoff and retry on TooManyRequ…
Browse files Browse the repository at this point in the history
…ests (#161)

* aws_api_gateway : Switch to jittered backoff and retry on TooManyRequests

* Mark aws_api_gateway stable again...

* Add changelog
  • Loading branch information
tremble authored Aug 28, 2020
1 parent 5e2d356 commit 6d404e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/161-retries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Add retries for aws_api_gateway when AWS throws `TooManyRequestsException`
10 changes: 5 additions & 5 deletions plugins/modules/aws_api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,25 +315,25 @@ def ensure_api_in_correct_state(module, client, api_id, api_data):
return configure_response, deploy_response


retry_params = {"tries": 10, "delay": 5, "backoff": 1.2}
retry_params = {"retries": 10, "delay": 10, "catch_extra_error_codes": ['TooManyRequestsException']}


@AWSRetry.backoff(**retry_params)
@AWSRetry.jittered_backoff(**retry_params)
def create_api(client, name=None, description=None, endpoint_type=None):
return client.create_rest_api(name="ansible-temp-api", description=description, endpointConfiguration={'types': [endpoint_type]})


@AWSRetry.backoff(**retry_params)
@AWSRetry.jittered_backoff(**retry_params)
def delete_api(client, api_id):
return client.delete_rest_api(restApiId=api_id)


@AWSRetry.backoff(**retry_params)
@AWSRetry.jittered_backoff(**retry_params)
def configure_api(client, api_id, api_data=None, mode="overwrite"):
return client.put_rest_api(restApiId=api_id, mode=mode, body=api_data)


@AWSRetry.backoff(**retry_params)
@AWSRetry.jittered_backoff(**retry_params)
def create_deployment(client, rest_api_id, **params):
canary_settings = params.get('stage_canary_settings')

Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/aws_api_gateway/aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
cloud/aws
shippable/aws/group2
# https://github.com/ansible-collections/community.aws/issues/158
unstable

0 comments on commit 6d404e3

Please sign in to comment.