From 9d51232911fb8e33ed565791419323f23913ef10 Mon Sep 17 00:00:00 2001 From: alexdebrie Date: Wed, 3 Dec 2014 22:23:58 -0600 Subject: [PATCH] Fix get_existing_cluster() function with multiple security groups The current get_existing_cluster() function would only find an instance belonged to a cluster if the instance's security groups == [cluster_name + "-master"] (or "-slaves"). This fix allows for multiple security groups by checking if the cluster_name + "-master" security group is in the list of groups for a particular instance. --- ec2/spark_ec2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py index b83decadc2988..6fdca205d0967 100755 --- a/ec2/spark_ec2.py +++ b/ec2/spark_ec2.py @@ -504,9 +504,9 @@ def get_existing_cluster(conn, opts, cluster_name, die_on_error=True): active = [i for i in res.instances if is_active(i)] for inst in active: group_names = [g.name for g in inst.groups] - if group_names == [cluster_name + "-master"]: + if cluster_name + "-master" in group_names: master_nodes.append(inst) - elif group_names == [cluster_name + "-slaves"]: + elif cluster_name + "-slaves" in group_names: slave_nodes.append(inst) if any((master_nodes, slave_nodes)): print "Found %d master(s), %d slaves" % (len(master_nodes), len(slave_nodes))