Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #286 from robfletcher/master
Browse files Browse the repository at this point in the history
Prevent bad reads from Edda marking ELBs as failing cross-zone balancing
  • Loading branch information
robfletcher committed Dec 14, 2016
2 parents 107bf20 + 04c73cc commit 50c4243
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;

import com.netflix.simianarmy.client.MonkeyRestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -70,12 +71,17 @@ public CrossZoneLoadBalancing(AWSCredentialsProvider awsCredentialsProvider) {
public Conformity check(Cluster cluster) {
Collection<String> failedComponents = Lists.newArrayList();
for (AutoScalingGroup asg : cluster.getAutoScalingGroups()) {
for (String lbName : getLoadBalancerNamesForAsg(cluster.getRegion(), asg.getName())) {
if (!isCrossZoneLoadBalancingEnabled(cluster.getRegion(), lbName)) {
LOGGER.info(String.format("ELB %s in %s does not have cross-zone load balancing enabled",
lbName, cluster.getRegion()));
failedComponents.add(lbName);
try {
for (String lbName : getLoadBalancerNamesForAsg(cluster.getRegion(), asg.getName())) {
if (!isCrossZoneLoadBalancingEnabled(cluster.getRegion(), lbName)) {
LOGGER.info(String.format("ELB %s in %s does not have cross-zone load balancing enabled",
lbName, cluster.getRegion()));
failedComponents.add(lbName);
}
}
} catch (MonkeyRestClient.DataReadException e) {
LOGGER.error(String.format("Transient error reading ELB for %s in %s - skipping this check",
asg.getName(), cluster.getRegion()), e);
}
}
return new Conformity(getName(), failedComponents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MonkeyRestClient(int timeout, int maxRetries, int retryInterval) {
Validate.isTrue(timeout >= 0);
Validate.isTrue(maxRetries >= 0);
Validate.isTrue(retryInterval > 0);

RequestConfig config = RequestConfig.custom()
.setConnectTimeout(timeout)
.build();
Expand Down Expand Up @@ -87,7 +87,7 @@ public JsonNode getJsonNodeFromUrl(String url) throws IOException {
if (code == 404) {
return null;
} else if (code >= 300 || code < 200) {
throw new RuntimeException(String.format("Response code %d from url %s: %s", code, url, jsonContent));
throw new DataReadException(code, url, jsonContent);
}

JsonNode result;
Expand All @@ -107,4 +107,10 @@ public JsonNode getJsonNodeFromUrl(String url) throws IOException {
* @return the base url in the region
*/
public abstract String getBaseUrl(String region);

public static class DataReadException extends RuntimeException {
public DataReadException(int code, String url, String jsonContent) {
super(String.format("Response code %d from url %s: %s", code, url, jsonContent));
}
}
}

0 comments on commit 50c4243

Please sign in to comment.