Retry in case of ephemeral errors

This commit is contained in:
Peter Eckersley 2016-01-20 14:25:01 -08:00
parent 122a36ebd2
commit b8281fdd34

View file

@ -139,7 +139,15 @@ def make_instance(instance_name,
time.sleep(1.0)
# give instance a name
new_instance.create_tags(Tags=[{'Key': 'Name', 'Value': instance_name}])
try:
new_instance.create_tags(Tags=[{'Key': 'Name', 'Value': instance_name}])
except botocore.exceptions.ClientError, e:
if "InvalidInstanceID.NotFound" in str(e):
# This seems to be ephemeral... retry
time.sleep(1)
new_instance.create_tags(Tags=[{'Key': 'Name', 'Value': instance_name}])
else:
raise
return new_instance
def terminate_and_clean(instances):