Skip to content

Commit

Permalink
ec2_ami - allow ImageAvailable waiter to retry when the image can't b…
Browse files Browse the repository at this point in the history
…e found (#1321)

ec2_ami - allow ImageAvailable waiter to retry when the image can't be found

SUMMARY
When using the image_available waiter shortly after triggering the creation of an AMI this can fail (Amazon sometimes return from creation calls, with an ID, before the APIs recognise that the resource exists)
Additionally splits up the AMI tests, it's sporadically timing out.  (taking a snapshot of a running instance is slow)
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_ami
ADDITIONAL INFORMATION
https://e7359f847acd480e3075-df27b72133198827a14e5ee13616eeff.ssl.cf1.rackcdn.com/periodic/github.com/ansible-collections/amazon.aws/main/integration-amazon.aws-target-ec2_ami/adb87fd/job-output.txt

Reviewed-by: Alina Buzachis <None>
  • Loading branch information
tremble authored Jan 9, 2023
1 parent ab5dfa1 commit 6da1aaa
Show file tree
Hide file tree
Showing 18 changed files with 1,154 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1321-ec2_ami.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- ec2_ami - allow ``ImageAvailable`` waiter to retry when the image can't be found (https://github.com/ansible-collections/amazon.aws/pull/1321).
5 changes: 5 additions & 0 deletions plugins/module_utils/waiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"argument": "Images[].State",
"expected": "available"
},
{
"matcher": "error",
"expected": "InvalidAMIID.NotFound",
"state": "retry"
},
{
"state": "failure",
"matcher": "pathAny",
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/targets/ec2_ami/aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
time=20m
# Split out, but sill needed for "nightly" tests (for now) - will remove once Zuul periodic job is
# updated
disabled

cloud/aws
ec2_ami_info
ec2_snapshot_info
5 changes: 5 additions & 0 deletions tests/integration/targets/ec2_ami_instance/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
time=30m
cloud/aws
ec2_ami
ec2_ami_info
ec2_snapshot_info
11 changes: 11 additions & 0 deletions tests/integration/targets/ec2_ami_instance/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
availability_zone: '{{ ec2_availability_zone_names[0] }}'

# defaults file for test_ec2_ami
ec2_ami_name: '{{ resource_prefix }}-ec2-ami'
ec2_ami_description: 'Created by Ansible ec2_ami integration tests'

ec2_ami_image: '{{ ec2_ami_id }}'

vpc_cidr: '10.{{ 256 | random(seed=resource_prefix) }}.0.0/16'
subnet_cidr: '10.{{ 256 | random(seed=resource_prefix) }}.1.0/24'
2 changes: 2 additions & 0 deletions tests/integration/targets/ec2_ami_instance/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- setup_ec2_facts
Loading

0 comments on commit 6da1aaa

Please sign in to comment.