Skip to content

Commit 27b0a36

Browse files
author
Jean-Martin Archer
committed
Listing of instances to be terminated before the prompt
Will list the EC2 instances before detroying the cluster. This was added because it can be scary to destroy EC2 instances without knowing which one will be impacted.
1 parent af3746c commit 27b0a36

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ec2/spark_ec2.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def launch_cluster(conn, opts, cluster_name):
223223
sys.exit(1)
224224
if opts.key_pair is None:
225225
print >> stderr, "ERROR: Must provide a key pair name (-k) to use on instances."
226-
sys.exit(1)
226+
sys.exit(1)
227227
print "Setting up security groups..."
228228
master_group = get_or_make_group(conn, cluster_name + "-master")
229229
slave_group = get_or_make_group(conn, cluster_name + "-slaves")
@@ -691,12 +691,18 @@ def real_main():
691691
setup_cluster(conn, master_nodes, slave_nodes, opts, True)
692692

693693
elif action == "destroy":
694-
response = raw_input("Are you sure you want to destroy the cluster " +
695-
cluster_name + "?\nALL DATA ON ALL NODES WILL BE LOST!!\n" +
694+
(master_nodes, slave_nodes) = get_existing_cluster(
695+
conn, opts, cluster_name, die_on_error=False)
696+
697+
print "Are you sure you want to destroy the cluster " + \
698+
cluster_name + "?\nThe following instances will be terminated:"
699+
for inst in master_nodes + slave_nodes:
700+
print inst
701+
702+
response = raw_input("ALL DATA ON ALL NODES WILL BE LOST!!\n" +
696703
"Destroy cluster " + cluster_name + " (y/N): ")
704+
697705
if response == "y":
698-
(master_nodes, slave_nodes) = get_existing_cluster(
699-
conn, opts, cluster_name, die_on_error=False)
700706
print "Terminating master..."
701707
for inst in master_nodes:
702708
inst.terminate()

0 commit comments

Comments
 (0)