diff --git a/priam/src/main/java/com/netflix/priam/IConfiguration.java b/priam/src/main/java/com/netflix/priam/IConfiguration.java index e53f2aee5..c99a4c85d 100644 --- a/priam/src/main/java/com/netflix/priam/IConfiguration.java +++ b/priam/src/main/java/com/netflix/priam/IConfiguration.java @@ -269,7 +269,12 @@ public interface IConfiguration * Amazon specific setting to query ASG Membership */ public String getASGName(); - + + /** + * Amazon specific setting to query Additional/ Sibling ASG Memberships in csv format to consider while calculating RAC membership + */ + public String getSiblingASGNames(); + /** * Get the security group associated with nodes in this cluster */ diff --git a/priam/src/main/java/com/netflix/priam/aws/AWSMembership.java b/priam/src/main/java/com/netflix/priam/aws/AWSMembership.java index 4d20afd09..dc1a973e8 100644 --- a/priam/src/main/java/com/netflix/priam/aws/AWSMembership.java +++ b/priam/src/main/java/com/netflix/priam/aws/AWSMembership.java @@ -17,10 +17,7 @@ import com.google.inject.name.Named; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import java.util.*; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -76,8 +73,11 @@ public List getRacMembership() AmazonAutoScaling client = null; try { + List asgNames = new ArrayList<>(); + asgNames.add(config.getASGName()); + asgNames.addAll(Arrays.asList(config.getSiblingASGNames().split("\\s*,\\s*"))); client = getAutoScalingClient(); - DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(config.getASGName()); + DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(asgNames.toArray(new String[asgNames.size()])); DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq); List instanceIds = Lists.newArrayList(); @@ -88,7 +88,7 @@ public List getRacMembership() .equalsIgnoreCase("Terminated"))) instanceIds.add(ins.getInstanceId()); } - logger.info(String.format("Querying Amazon returned following instance in the ASG: %s --> %s", config.getRac(), StringUtils.join(instanceIds, ","))); + logger.info(String.format("Querying Amazon returned following instance in the RAC: %s, ASGs: %s --> %s", config.getRac(),StringUtils.join(asgNames, ",") ,StringUtils.join(instanceIds, ","))); return instanceIds; } finally diff --git a/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java b/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java index c6954f299..c961c084c 100644 --- a/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java +++ b/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java @@ -174,6 +174,7 @@ public class PriamConfiguration implements IConfiguration // Amazon specific private static final String CONFIG_ASG_NAME = PRIAM_PRE + ".az.asgname"; + private static final String CONFIG_SIBLING_ASG_NAMES = PRIAM_PRE + ".az.sibling.asgnames"; private static final String CONFIG_REGION_NAME = PRIAM_PRE + ".az.region"; private static final String CONFIG_ACL_GROUP_NAME = PRIAM_PRE + ".acl.groupname"; private final String LOCAL_HOSTNAME = SystemUtils.getDataFromUrl("http://169.254.169.254/latest/meta-data/local-hostname").trim(); @@ -682,6 +683,14 @@ public String getASGName() return config.get(CONFIG_ASG_NAME, ""); } + /** + * Amazon specific setting to query Additional/ Sibling ASG Memberships in csv format to consider while calculating RAC membership + */ + @Override + public String getSiblingASGNames() { + return config.get(CONFIG_SIBLING_ASG_NAMES, ","); + } + @Override public String getACLGroupName() { diff --git a/priam/src/test/java/com/netflix/priam/FakeConfiguration.java b/priam/src/test/java/com/netflix/priam/FakeConfiguration.java index 683e9e10f..d7bd02c43 100644 --- a/priam/src/test/java/com/netflix/priam/FakeConfiguration.java +++ b/priam/src/test/java/com/netflix/priam/FakeConfiguration.java @@ -226,7 +226,15 @@ public String getASGName() // TODO Auto-generated method stub return null; } - + + /** + * Amazon specific setting to query Additional/ Sibling ASG Memberships in csv format to consider while calculating RAC membership + */ + @Override + public String getSiblingASGNames() { + return null; + } + @Override public boolean isIncrBackup() { diff --git a/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java b/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java index a39a9fddb..eb7670ad1 100644 --- a/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java +++ b/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java @@ -227,6 +227,14 @@ public String getASGName() return null; } + /** + * Amazon specific setting to query Additional/ Sibling ASG Memberships in csv format to consider while calculating RAC membership + */ + @Override + public String getSiblingASGNames() { + return null; + } + @Override public boolean isIncrBackup() {