Skip to content

Commit 5f1f4dc

Browse files
authored
Add a separate method for rerouting with reset failed counter (#115896)
A cluster resets failed counter and calls reroute on node-join. This is a background activity not directly initiated by end-users. Currently it uses the same reroute method that handles the reoute API. This creates some ambiguity on the method's scope. This PR adds a new dedicate method for this use case and leave the existing one dedicated for API usage.
1 parent a3a312f commit 5f1f4dc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ public void addAllocFailuresResetListenerTo(ClusterService clusterService) {
572572
// set retryFailed=true to trigger failures reset during reroute
573573
var taskQueue = clusterService.createTaskQueue("reset-allocation-failures", Priority.NORMAL, (batchCtx) -> {
574574
batchCtx.taskContexts().forEach((taskCtx) -> taskCtx.success(() -> {}));
575-
return reroute(batchCtx.initialState(), new AllocationCommands(), false, true, false, ActionListener.noop()).clusterState();
575+
return rerouteWithResetFailedCounter(batchCtx.initialState());
576576
});
577577

578578
clusterService.addListener((changeEvent) -> {
@@ -582,6 +582,13 @@ public void addAllocFailuresResetListenerTo(ClusterService clusterService) {
582582
});
583583
}
584584

585+
private ClusterState rerouteWithResetFailedCounter(ClusterState clusterState) {
586+
RoutingAllocation allocation = createRoutingAllocation(clusterState, currentNanoTime());
587+
allocation.routingNodes().resetFailedCounter(allocation.changes());
588+
reroute(allocation, routingAllocation -> shardsAllocator.allocate(routingAllocation, ActionListener.noop()));
589+
return buildResultAndLogHealthChange(clusterState, allocation, "reroute with reset failed counter");
590+
}
591+
585592
private static void disassociateDeadNodes(RoutingAllocation allocation) {
586593
for (Iterator<RoutingNode> it = allocation.routingNodes().mutableIterator(); it.hasNext();) {
587594
RoutingNode node = it.next();

0 commit comments

Comments
 (0)