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 terminate(List<String> ips);
|
||||||
|
|
||||||
|
public AutoScalingData terminateWithIds(List<String> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a lookup of ip addresses to node ids
|
* Provides a lookup of ip addresses to node ids
|
||||||
* @param ips - nodes IPs
|
* @param ips - nodes IPs
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("Terminating instance[%s]", instances);
|
log.info("Terminating instances[%s]", instances);
|
||||||
amazonEC2Client.terminateInstances(
|
amazonEC2Client.terminateInstances(
|
||||||
new TerminateInstancesRequest(
|
new TerminateInstancesRequest(
|
||||||
Lists.transform(
|
Lists.transform(
|
||||||
|
@ -193,6 +193,28 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy
|
||||||
return null;
|
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
|
@Override
|
||||||
public List<String> ipToIdLookup(List<String> ips)
|
public List<String> ipToIdLookup(List<String> ips)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,13 @@ public class NoopAutoScalingStrategy implements AutoScalingStrategy
|
||||||
return null;
|
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
|
@Override
|
||||||
public List<String> ipToIdLookup(List<String> ips)
|
public List<String> ipToIdLookup(List<String> ips)
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,8 +132,7 @@ public class SimpleResourceManagementStrategy implements ResourceManagementStrat
|
||||||
.addData("provisioningCount", currentlyProvisioning.size())
|
.addData("provisioningCount", currentlyProvisioning.size())
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
List<String> nodeIps = autoScalingStrategy.idToIpLookup(Lists.newArrayList(currentlyProvisioning));
|
autoScalingStrategy.terminateWithIds(Lists.newArrayList(currentlyProvisioning));
|
||||||
autoScalingStrategy.terminate(nodeIps);
|
|
||||||
currentlyProvisioning.clear();
|
currentlyProvisioning.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,9 +187,7 @@ public class SimpleResourceManagementStrategyTest
|
||||||
|
|
||||||
EasyMock.expect(autoScalingStrategy.ipToIdLookup(EasyMock.<List<String>>anyObject()))
|
EasyMock.expect(autoScalingStrategy.ipToIdLookup(EasyMock.<List<String>>anyObject()))
|
||||||
.andReturn(Lists.<String>newArrayList()).times(2);
|
.andReturn(Lists.<String>newArrayList()).times(2);
|
||||||
EasyMock.expect(autoScalingStrategy.idToIpLookup(EasyMock.<List<String>>anyObject()))
|
EasyMock.expect(autoScalingStrategy.terminateWithIds(EasyMock.<List<String>>anyObject()))
|
||||||
.andReturn(Lists.<String>newArrayList());
|
|
||||||
EasyMock.expect(autoScalingStrategy.terminate(EasyMock.<List<String>>anyObject()))
|
|
||||||
.andReturn(null);
|
.andReturn(null);
|
||||||
EasyMock.expect(autoScalingStrategy.provision()).andReturn(
|
EasyMock.expect(autoScalingStrategy.provision()).andReturn(
|
||||||
new AutoScalingData(Lists.<String>newArrayList("fake"))
|
new AutoScalingData(Lists.<String>newArrayList("fake"))
|
||||||
|
|
|
@ -37,6 +37,12 @@ public class TestAutoScalingStrategy<T> implements AutoScalingStrategy
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AutoScalingData terminateWithIds(List<String> ids)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> ipToIdLookup(List<String> ips)
|
public List<String> ipToIdLookup(List<String> ips)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue