diff options
author | Peter Sankauskas <peter@admobius.com> | 2012-12-10 17:44:09 -0800 |
---|---|---|
committer | Peter Sankauskas <peter@admobius.com> | 2012-12-10 17:44:09 -0800 |
commit | 9f964612a1e3f1c80de52e1015dee510489ad8ed (patch) | |
tree | db9b18834d4a048e4a7247d7c7432c7aebc60074 /ec2 | |
parent | beb440089ec5a9fa89255c2932f7f8e98c6a4b7c (diff) | |
download | spark-9f964612a1e3f1c80de52e1015dee510489ad8ed.tar.gz spark-9f964612a1e3f1c80de52e1015dee510489ad8ed.tar.bz2 spark-9f964612a1e3f1c80de52e1015dee510489ad8ed.zip |
SPARK-626: Remove rules before removing security groups, with a pause in
between so wait for AWS eventual consistency to catch up.
Diffstat (limited to 'ec2')
-rwxr-xr-x | ec2/spark_ec2.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py index 2ab11dbd34..2e8d2e17f5 100755 --- a/ec2/spark_ec2.py +++ b/ec2/spark_ec2.py @@ -557,18 +557,22 @@ def main(): inst.terminate() # Delete security groups as well group_names = [cluster_name + "-master", cluster_name + "-slaves", cluster_name + "-zoo"] - groups = conn.get_all_security_groups() + groups = [g for g in conn.get_all_security_groups() if g.name in group_names] + # Delete individual rules in all groups before deleting groups to remove + # dependencies between them for group in groups: - if group.name in group_names: - print "Deleting security group " + group.name - # Delete individual rules before deleting group to remove dependencies - for rule in group.rules: - for grant in rule.grants: - group.revoke(ip_protocol=rule.ip_protocol, - from_port=rule.from_port, - to_port=rule.to_port, - src_group=grant) - conn.delete_security_group(group.name) + print "Deleting rules in security group " + group.name + for rule in group.rules: + for grant in rule.grants: + group.revoke(ip_protocol=rule.ip_protocol, + from_port=rule.from_port, + to_port=rule.to_port, + src_group=grant) + # Sleep for AWS eventual-consistency to catch up + time.sleep(30) # Yes, it does have to be this long :-( + for group in groups: + print "Deleting security group " + group.name + conn.delete_security_group(group.name) elif action == "login": (master_nodes, slave_nodes, zoo_nodes) = get_existing_cluster( |