Skip to content

Commit

Permalink
ec2_instance: Fix spurious error message when we lose a race (#7)
Browse files Browse the repository at this point in the history
It is possible for all instances to stop matching the filters between
the initial check for existing instances and the first call to
find_instances() in change_instance_state().

If this happened, find_instances() would previously be called a second
time with an empty list of instance IDs and no filters, which should
not happen and immediately ends module execution with the error "No
filters provided when they were required".
  • Loading branch information
flowerysong authored Aug 15, 2020
1 parent 2a4f70d commit 75fdfbf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,9 @@ def change_instance_state(filters, desired_state, ec2=None):
await_instances(ids=list(changed) + list(unchanged), state=desired_state)

change_failed = list(to_change - changed)
instances = find_instances(ec2, ids=list(i['InstanceId'] for i in instances))

if instances:
instances = find_instances(ec2, ids=list(i['InstanceId'] for i in instances))
return changed, change_failed, instances, failure_reason


Expand Down

0 comments on commit 75fdfbf

Please sign in to comment.