Skip to content

Commit

Permalink
Ignore TERMINATED instances
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dadoonet committed Jun 28, 2013
1 parent 703c2b3 commit 0a088c6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/elasticsearch/cloud/gce/GceComputeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static final class Fields {
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;
Expand Down Expand Up @@ -114,6 +118,13 @@ private List<DiscoveryNode> buildNodes(String project, String zone) throws IOExc

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) {
Expand Down

0 comments on commit 0a088c6

Please sign in to comment.