Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#eng-3631] Fail-open when nodeFsStats were unable to be retrieved.

  • Loading branch information...
commit ac854ad997af9c0b7afafe1f1d37fa1de1545e19 1 parent daeb15c
@dakrone dakrone authored
View
11 src/main/java/com/sonian/elasticsearch/equilibrium/DiskShardsAllocator.java
@@ -105,8 +105,7 @@ public boolean allocateUnassigned(RoutingAllocation allocation) {
RoutingNodes routingNodes = allocation.routingNodes();
NodesStatsResponse stats = this.nodeInfoHelper.nodeFsStats();
if (stats == null) {
- logger.warn("Unable to determine nodeFsStats, aborting allocation.");
- return false;
+ logger.error("Unable to determine nodeFsStats! Continuing allocation with fail-open.");
}
RoutingNode[] nodes = sortedNodesByShardCountLeastToHigh(allocation);
@@ -481,8 +480,7 @@ public boolean move(MutableShardRouting shardRouting, RoutingNode node, RoutingA
}
NodesStatsResponse stats = this.nodeInfoHelper.nodeFsStats();
if (stats == null) {
- logger.warn("Unable to determine nodeFsStats, aborting shard move.");
- return false;
+ logger.error("Unable to determine nodeFsStats! Continuing shard move with fail-open.");
}
RoutingNode[] sortedNodesLeastToHigh = sortedNodesByShardCountLeastToHigh(allocation);
@@ -697,6 +695,11 @@ public boolean enoughDiskForShard(final MutableShardRouting shard, final Routing
logger.info("enoughDiskForShard on {} for: {}", routingNode.nodeId(), shard.shardId());
+ if (null == nodeStats) {
+ logger.warn("Unable to check for enough disk space, nodeStats were not provided. Failing open (true).");
+ return true;
+ }
+
String nodeId = routingNode.nodeId();
Map<String, NodeStats> nodeStatsMap = nodeStats.getNodesMap();
NodeStats ns = nodeStatsMap.get(nodeId);
View
2  src/test/java/com/sonian/elasticsearch/equilibrium/DiskShardsAllocatorUnitTests.java
@@ -85,9 +85,11 @@ public void testEnoughDiskForShard() {
boolean resp1 = dsa.enoughDiskForShard(msr, node, smallNSR);
boolean resp2 = dsa.enoughDiskForShard(msr, node, largeNSR);
+ boolean resp3 = dsa.enoughDiskForShard(msr, node, null);
assertThat("we don't have enough disk on the small node", resp1 == false);
assertThat("we do have enough disk on the large node", resp2 == true);
+ assertThat("passing null for nodeFsStats fails open", resp3 == true);
}
Please sign in to comment.
Something went wrong with that request. Please try again.