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 AWSRetry.jittered_backoff to rds_instance_info #1026

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/1026-aws-retry-rds-instance-info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- rds_instance_info - add retries on common AWS failures (https://github.com/ansible-collections/community.aws/pull/1026).
18 changes: 13 additions & 5 deletions plugins/modules/rds_instance_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,17 @@
pass # handled by AnsibleAWSModule


@AWSRetry.jittered_backoff()
tremble marked this conversation as resolved.
Show resolved Hide resolved
def _describe_db_instances(conn, **params):
paginator = conn.get_paginator('describe_db_instances')
try:
results = paginator.paginate(**params).build_full_result()['DBInstances']
except is_boto3_error_code('DBInstanceNotFound'):
results = []

return results


def instance_info(module, conn):
instance_name = module.params.get('db_instance_identifier')
filters = module.params.get('filters')
Expand All @@ -375,12 +386,9 @@ def instance_info(module, conn):
if filters:
params['Filters'] = ansible_dict_to_boto3_filter_list(filters)

paginator = conn.get_paginator('describe_db_instances')
try:
results = paginator.paginate(**params).build_full_result()['DBInstances']
except is_boto3_error_code('DBInstanceNotFound'):
results = []
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except
results = _describe_db_instances(conn, **params)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, "Couldn't get instance information")

for instance in results:
Expand Down