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:
David Pilato 2013-06-28 15:49:18 +02:00
parent 703c2b3e82
commit 0a088c6a0c
1 changed files with 11 additions and 0 deletions

View File

@ -58,6 +58,10 @@ public class GceComputeService extends AbstractLifecycleComponent<GceComputeServ
private static final String VERSION = "Elasticsearch/GceCloud/1.0";
}
static final class Status {
private static final String TERMINATED = "TERMINATED";
}
private List<DiscoveryNode> discoNodes;
private TransportService transportService;
private NetworkService networkService;
@ -114,6 +118,13 @@ public class GceComputeService extends AbstractLifecycleComponent<GceComputeServ
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
boolean filterByTag = false;
if (tags.length > 0) {