Skip to content

Commit

Permalink
add InvalidInstanceID.NotFound to the list of error codes that should…
Browse files Browse the repository at this point in the history
… trigger a retry (catch_extra_error_codes)
  • Loading branch information
tchernomax committed Oct 15, 2023
1 parent ad43bd4 commit b0f124b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
bugfixes:
- ec2_instance - retry API call if we get ``InvalidGroup.NotFound`` error (https://github.com/ansible-collections/amazon.aws/pull/1650).
- ec2_instance - retry API call if we get ``InvalidInstanceID.NotFound`` error (https://github.com/ansible-collections/amazon.aws/pull/1650).
7 changes: 6 additions & 1 deletion plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,12 @@ def ensure_present(existing_matches, desired_module_state, current_count=None):
for ins in instances:
# Wait for instances to exist (don't check state)
try:
client.describe_instance_status(InstanceIds=[ins["InstanceId"]], IncludeAllInstances=True)
AWSRetry.jittered_backoff(
catch_extra_error_codes=["InvalidInstanceID.NotFound"],
)(client.describe_instance_status)(
InstanceIds=[ins["InstanceId"]],
IncludeAllInstances=True,
)
except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e:
module.fail_json_aws(e, msg="Failed to fetch status of new EC2 instance")
changes = diff_instance_and_params(ins, module.params, skip=["UserData", "EbsOptimized"])
Expand Down

0 comments on commit b0f124b

Please sign in to comment.