Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the ability to query more than one ASG for RacMembership #528

Merged
merged 1 commit into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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