Skip to content

Commit de7f3fd

Browse files
author
Gabriel Monroy
committed
workaround for ec2 race condition
there's an ec2 race condition on instances terminating uccessfully but still holding a lock on the security group. let's take a nap.
1 parent c7fdf8c commit de7f3fd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

celerytasks/ec2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def build_layer(layer, creds, params):
4040

4141
@task(name='ec2.destroy_layer')
4242
def destroy_layer(layer, creds, params):
43+
# there's an ec2 race condition on instances terminating
44+
# successfully but still holding a lock on the security group
45+
# let's take a nap
46+
time.sleep(5)
4347
region = params.get('region', 'us-east-1')
4448
conn = create_ec2_connection(
4549
region, creds['access_key'], creds['secret_key'])
@@ -184,7 +188,7 @@ def prepare_run_kwargs(params, init):
184188
'kernel_id': params.get('kernel', None),
185189
}
186190
# update user_data
187-
cloud_config = '#cloud-config\n'+yaml.safe_dump(init)
191+
cloud_config = '#cloud-config\n' + yaml.safe_dump(init)
188192
kwargs.update({'user_data': cloud_config})
189193
# params override defaults
190194
kwargs.update(param_kwargs)

0 commit comments

Comments
 (0)