use of com.netflix.simianarmy.conformity.AutoScalingGroup in project SimianArmy by Netflix.
the class InstanceIsHealthyInEureka method check.
@Override
public Conformity check(Cluster cluster) {
Collection<String> failedComponents = Lists.newArrayList();
for (AutoScalingGroup asg : cluster.getAutoScalingGroups()) {
// ignore suspended ASGs
if (asg.isSuspended()) {
LOGGER.info(String.format("ASG %s is suspended, ignore.", asg.getName()));
continue;
}
for (String instance : asg.getInstances()) {
if (!conformityEurekaClient.isHealthy(cluster.getRegion(), instance)) {
LOGGER.info(String.format("Instance %s is not healthy in Eureka.", instance));
failedComponents.add(instance);
}
}
}
return new Conformity(getName(), failedComponents);
}
use of com.netflix.simianarmy.conformity.AutoScalingGroup in project SimianArmy by Netflix.
the class InstanceTooOld method check.
@Override
public Conformity check(Cluster cluster) {
List<String> instanceIds = Lists.newArrayList();
for (AutoScalingGroup asg : cluster.getAutoScalingGroups()) {
instanceIds.addAll(asg.getInstances());
}
Map<String, Long> instanceIdToLaunchTime = getInstanceLaunchTimes(cluster.getRegion(), instanceIds.toArray(new String[instanceIds.size()]));
Collection<String> failedComponents = Lists.newArrayList();
long creationTimeThreshold = DateTime.now().minusDays(instanceAgeThreshold).getMillis();
for (Map.Entry<String, Long> entry : instanceIdToLaunchTime.entrySet()) {
String instanceId = entry.getKey();
if (creationTimeThreshold > entry.getValue()) {
LOGGER.info(String.format("Instance %s was created more than %d days ago", instanceId, instanceAgeThreshold));
failedComponents.add(instanceId);
}
}
return new Conformity(getName(), failedComponents);
}
use of com.netflix.simianarmy.conformity.AutoScalingGroup in project SimianArmy by Netflix.
the class SameZonesInElbAndAsg method check.
@Override
public Conformity check(Cluster cluster) {
List<String> asgNames = Lists.newArrayList();
for (AutoScalingGroup asg : cluster.getAutoScalingGroups()) {
asgNames.add(asg.getName());
}
Collection<String> failedComponents = Lists.newArrayList();
for (AutoScalingGroup asg : cluster.getAutoScalingGroups()) {
List<String> asgZones = getAvailabilityZonesForAsg(cluster.getRegion(), asg.getName());
for (String lbName : getLoadBalancerNamesForAsg(cluster.getRegion(), asg.getName())) {
List<String> lbZones = getAvailabilityZonesForLoadBalancer(cluster.getRegion(), lbName);
if (!haveSameZones(asgZones, lbZones)) {
LOGGER.info(String.format("ASG %s and ELB %s do not have the same availability zones", asgZones, lbZones));
failedComponents.add(lbName);
}
}
}
return new Conformity(getName(), failedComponents);
}
use of com.netflix.simianarmy.conformity.AutoScalingGroup in project SimianArmy by Netflix.
the class TestInstanceInVPC method testAsgInstances.
@Test
public void testAsgInstances() throws Exception {
AutoScalingGroup autoScalingGroup = new AutoScalingGroup("Conforming", VPC_INSTANCE_ID);
Cluster conformingCluster = new Cluster("Conforming", REGION, autoScalingGroup);
Conformity result = instanceInVPC.check(conformingCluster);
Assert.assertNotNull(result);
Assert.assertEquals(result.getRuleId(), instanceInVPC.getName());
Assert.assertEquals(result.getFailedComponents().size(), 0);
autoScalingGroup = new AutoScalingGroup("NonConforming", INSTANCE_ID);
Cluster nonConformingCluster = new Cluster("NonConforming", REGION, autoScalingGroup);
result = instanceInVPC.check(nonConformingCluster);
Assert.assertNotNull(result);
Assert.assertEquals(result.getRuleId(), instanceInVPC.getName());
Assert.assertEquals(result.getFailedComponents().size(), 1);
Assert.assertEquals(result.getFailedComponents().iterator().next(), INSTANCE_ID);
}
Aggregations