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

Commit

Permalink
Prevent bad reads from Edda marking ELBs as failing cross-zone balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Dec 13, 2016
1 parent 107bf20 commit 04c73cc
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 04c73cc

Please sign in to comment.