Skip to content

Commit 85afc09

Browse files
committed
Fixed #129 -- work around EC2's laggy create_security_group().
1 parent 784358a commit 85afc09

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

celerytasks/ec2.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@ def build_layer(layer, creds, params):
3535
# create a new sg and authorize all ports
3636
# use iptables on the host to firewall ports
3737
sg = conn.create_security_group(layer, 'Created by Deis')
38-
sg.authorize(ip_protocol='tcp', from_port=1, to_port=65535,
39-
cidr_ip='0.0.0.0/0')
38+
# loop until the sg is *actually* there
39+
for i in xrange(10):
40+
try:
41+
sg.authorize(ip_protocol='tcp', from_port=1, to_port=65535,
42+
cidr_ip='0.0.0.0/0')
43+
break
44+
except EC2ResponseError:
45+
if i < 10:
46+
time.sleep(1.5)
47+
continue
48+
else:
49+
raise
4050

4151

4252
@task(name='ec2.destroy_layer')

0 commit comments

Comments
 (0)