Skip to content

Commit

Permalink
[#eng-3631] Fail-open when nodeFsStats were unable to be retrieved.
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed Jan 29, 2013
1 parent daeb15c commit ac854ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down

0 comments on commit ac854ad

Please sign in to comment.