Skip to content

Commit

Permalink
Catch AmazonClientExceptions to prevent connection loss
Browse files Browse the repository at this point in the history
If the AWS client throws an exception (e.g: because of a DNS failure) it will end up killing the rejoin thread and stop retrying which can lead to a node getting stuck unable to rejoin the cluster.

Closes #30.
  • Loading branch information
Gianni O'Neill authored and dadoonet committed Aug 9, 2013
1 parent 906326d commit 4da9b2c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.discovery.ec2;

import com.amazonaws.AmazonClientException;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.model.*;
import org.elasticsearch.Version;
Expand Down Expand Up @@ -96,7 +97,14 @@ public AwsEc2UnicastHostsProvider(Settings settings, TransportService transportS
public List<DiscoveryNode> buildDynamicNodes() {
List<DiscoveryNode> discoNodes = Lists.newArrayList();

DescribeInstancesResult descInstances = client.describeInstances(new DescribeInstancesRequest());
DescribeInstancesResult descInstances;
try {
descInstances = client.describeInstances(new DescribeInstancesRequest());
} catch (AmazonClientException e) {
logger.info("Exception while retrieving instance list from AWS API: {}", e.getMessage());
logger.debug("Full exception:", e);
return discoNodes;
}

logger.trace("building dynamic unicast discovery nodes...");
for (Reservation reservation : descInstances.getReservations()) {
Expand Down

0 comments on commit 4da9b2c

Please sign in to comment.