From 45cf1dbbc5421539c99a0b6310752278f4ff244f Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Mon, 23 Jun 2014 16:58:07 -0400 Subject: [PATCH] Fixing issue #7906 Catch any InvalidInstanceID.NotFound errors coming from the boto library when trying to find the newly created instance. When this happens We should just wait and try again. --- library/cloud/ec2 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/cloud/ec2 b/library/cloud/ec2 index 44513c08848..fd4ef0d8e78 100644 --- a/library/cloud/ec2 +++ b/library/cloud/ec2 @@ -921,7 +921,15 @@ def create_instances(module, ec2, override_count=None): num_running = 0 wait_timeout = time.time() + wait_timeout while wait_timeout > time.time() and num_running < len(instids): - res_list = ec2.get_all_instances(instids) + try: + res_list = ec2.get_all_instances(instids) + except boto.exception.BotoSeverError, e: + if e.error_code == 'InvalidInstanceID.NotFound': + time.sleep(1) + continue + else: + raise + num_running = 0 for res in res_list: num_running += len([ i for i in res.instances if i.state=='running' ])