Ignore TERMINATED instances
When an instance is removed, its status become `TERMINATED`. As stated in [GCE Documentation](https://developers.google.com/compute/docs/instances#checkmachinestatus): > TERMINATED - The instance either failed for some reason or was shutdown. This is a permanent status, and the only way to repair the instance is to delete and recreate it. So we need to ignore instances with such a status. Closes #3.
This commit is contained in:
parent
703c2b3e82
commit
0a088c6a0c
|
@ -58,6 +58,10 @@ public class GceComputeService extends AbstractLifecycleComponent<GceComputeServ
|
||||||
private static final String VERSION = "Elasticsearch/GceCloud/1.0";
|
private static final String VERSION = "Elasticsearch/GceCloud/1.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final class Status {
|
||||||
|
private static final String TERMINATED = "TERMINATED";
|
||||||
|
}
|
||||||
|
|
||||||
private List<DiscoveryNode> discoNodes;
|
private List<DiscoveryNode> discoNodes;
|
||||||
private TransportService transportService;
|
private TransportService transportService;
|
||||||
private NetworkService networkService;
|
private NetworkService networkService;
|
||||||
|
@ -114,6 +118,13 @@ public class GceComputeService extends AbstractLifecycleComponent<GceComputeServ
|
||||||
|
|
||||||
String status = instance.getStatus();
|
String status = instance.getStatus();
|
||||||
|
|
||||||
|
// We don't want to connect to TERMINATED status instances
|
||||||
|
// See https://github.com/elasticsearch/elasticsearch-cloud-gce/issues/3
|
||||||
|
if (Status.TERMINATED.equals(status)) {
|
||||||
|
logger.debug("node {} is TERMINATED. Ignoring", name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// see if we need to filter by tag
|
// see if we need to filter by tag
|
||||||
boolean filterByTag = false;
|
boolean filterByTag = false;
|
||||||
if (tags.length > 0) {
|
if (tags.length > 0) {
|
||||||
|
|
Loading…
Reference in New Issue