diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 5c8d7e1f00a31..60634684ed0c8 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -317,7 +317,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl "this shard is not allocated on the most utilized disk and can remain"); } if (freeBytes < 0L) { - final long sizeOfRelocatingShards = sizeOfRelocatingShards(node, false, usage.getPath(), + final long sizeOfRelocatingShards = sizeOfRelocatingShards(node, true, usage.getPath(), allocation.clusterInfo(), allocation.metaData(), allocation.routingTable()); logger.debug("fewer free bytes remaining than the size of all incoming shards: " + "usage {} on node {} including {} bytes of relocations, shard cannot remain", diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java index 93d87edad4d5f..d0a79a5a7834c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java @@ -754,17 +754,13 @@ public void testShardRelocationsTakenIntoAccount() { AllocationCommand moveAllocationCommand = new MoveAllocationCommand("test2", 0, "node2", "node3"); AllocationCommands cmds = new AllocationCommands(moveAllocationCommand); - logger.info("--> before starting: {}", clusterState); clusterState = startInitializingShardsAndReroute(strategy, clusterState); - logger.info("--> after starting: {}", clusterState); clusterState = strategy.reroute(clusterState, cmds, false, false).getClusterState(); - logger.info("--> after running another command: {}", clusterState); logShardStates(clusterState); clusterInfoReference.set(overfullClusterInfo); - clusterState = strategy.reroute(clusterState, "foo"); - logger.info("--> after another reroute: {}", clusterState); + strategy.reroute(clusterState, "foo"); // ensure reroute doesn't fail even though there is negative free space } }