Skip to content

Commit

Permalink
Merge pull request #528 from vinaykumarchella/3.x
Browse files Browse the repository at this point in the history
Support the ability to query more than one ASG for RacMembership
  • Loading branch information
vinaykumarchella authored Oct 5, 2016
2 parents 2e8891a + b8aefbd commit 08963a1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
7 changes: 6 additions & 1 deletion priam/src/main/java/com/netflix/priam/IConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 6 additions & 6 deletions priam/src/main/java/com/netflix/priam/aws/AWSMembership.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,8 +73,11 @@ public List<String> getRacMembership()
AmazonAutoScaling client = null;
try
{
List<String> 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<String> instanceIds = Lists.newArrayList();
Expand All @@ -88,7 +88,7 @@ public List<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
{
Expand Down
10 changes: 9 additions & 1 deletion priam/src/test/java/com/netflix/priam/FakeConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 08963a1

Please sign in to comment.