mirror of https://github.com/apache/druid.git
fix the edge case where autoscaling tries to terminate node without ip
This commit is contained in:
parent
1057e2e165
commit
1ecc9d0f98
|
@ -30,6 +30,8 @@ public interface AutoScalingStrategy
|
|||
|
||||
public AutoScalingData terminate(List<String> ips);
|
||||
|
||||
public AutoScalingData terminateWithIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* Provides a lookup of ip addresses to node ids
|
||||
* @param ips - nodes IPs
|
||||
|
|
|
@ -155,7 +155,7 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy
|
|||
}
|
||||
|
||||
try {
|
||||
log.info("Terminating instance[%s]", instances);
|
||||
log.info("Terminating instances[%s]", instances);
|
||||
amazonEC2Client.terminateInstances(
|
||||
new TerminateInstancesRequest(
|
||||
Lists.transform(
|
||||
|
@ -193,6 +193,28 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoScalingData terminateWithIds(List<String> ids)
|
||||
{
|
||||
if (ids.isEmpty()) {
|
||||
return new AutoScalingData(Lists.<String>newArrayList());
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("Terminating instances[%s]", ids);
|
||||
amazonEC2Client.terminateInstances(
|
||||
new TerminateInstancesRequest(ids)
|
||||
);
|
||||
|
||||
return new AutoScalingData(ids);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e, "Unable to terminate any instances.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> ipToIdLookup(List<String> ips)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,13 @@ public class NoopAutoScalingStrategy implements AutoScalingStrategy
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoScalingData terminateWithIds(List<String> ids)
|
||||
{
|
||||
log.info("If I were a real strategy I'd terminate %s now", ids);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> ipToIdLookup(List<String> ips)
|
||||
{
|
||||
|
|
|
@ -132,8 +132,7 @@ public class SimpleResourceManagementStrategy implements ResourceManagementStrat
|
|||
.addData("provisioningCount", currentlyProvisioning.size())
|
||||
.emit();
|
||||
|
||||
List<String> nodeIps = autoScalingStrategy.idToIpLookup(Lists.newArrayList(currentlyProvisioning));
|
||||
autoScalingStrategy.terminate(nodeIps);
|
||||
autoScalingStrategy.terminateWithIds(Lists.newArrayList(currentlyProvisioning));
|
||||
currentlyProvisioning.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,9 +187,7 @@ public class SimpleResourceManagementStrategyTest
|
|||
|
||||
EasyMock.expect(autoScalingStrategy.ipToIdLookup(EasyMock.<List<String>>anyObject()))
|
||||
.andReturn(Lists.<String>newArrayList()).times(2);
|
||||
EasyMock.expect(autoScalingStrategy.idToIpLookup(EasyMock.<List<String>>anyObject()))
|
||||
.andReturn(Lists.<String>newArrayList());
|
||||
EasyMock.expect(autoScalingStrategy.terminate(EasyMock.<List<String>>anyObject()))
|
||||
EasyMock.expect(autoScalingStrategy.terminateWithIds(EasyMock.<List<String>>anyObject()))
|
||||
.andReturn(null);
|
||||
EasyMock.expect(autoScalingStrategy.provision()).andReturn(
|
||||
new AutoScalingData(Lists.<String>newArrayList("fake"))
|
||||
|
|
|
@ -37,6 +37,12 @@ public class TestAutoScalingStrategy<T> implements AutoScalingStrategy
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoScalingData terminateWithIds(List<String> ids)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> ipToIdLookup(List<String> ips)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue