Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug mode in MaxRetryAllocationDecider #89973

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/89973.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 89973
summary: Fix debug mode in `MaxRetryAllocationDecider`
area: Allocation
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static Decision decisionWithFailures(
}

private static Decision debugDecision(Decision decision, UnassignedInfo unassignedInfo, int numFailedAllocations, int maxRetry) {
if (decision.type() == Decision.Type.YES) {
if (decision.type() == Decision.Type.NO) {
return Decision.single(
Decision.Type.NO,
NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,8 @@ public void testFailedAllocation() {
assertThat(unassignedPrimary.unassignedInfo().getMessage(), containsString("boom" + i));
// MaxRetryAllocationDecider#canForceAllocatePrimary should return YES decisions because canAllocate returns YES here
assertEquals(
Decision.YES,
new MaxRetryAllocationDecider().canForceAllocatePrimary(
unassignedPrimary,
null,
new RoutingAllocation(null, clusterState, null, null, 0)
)
Decision.Type.YES,
new MaxRetryAllocationDecider().canForceAllocatePrimary(unassignedPrimary, null, newRoutingAllocation(clusterState)).type()
);
}
// now we go and check that we are actually stick to unassigned on the next failure
Expand All @@ -207,12 +203,8 @@ public void testFailedAllocation() {
assertThat(unassignedPrimary.unassignedInfo().getMessage(), containsString("boom"));
// MaxRetryAllocationDecider#canForceAllocatePrimary should return a NO decision because canAllocate returns NO here
assertEquals(
Decision.NO,
new MaxRetryAllocationDecider().canForceAllocatePrimary(
unassignedPrimary,
null,
new RoutingAllocation(null, clusterState, null, null, 0)
)
Decision.Type.NO,
new MaxRetryAllocationDecider().canForceAllocatePrimary(unassignedPrimary, null, newRoutingAllocation(clusterState)).type()
);
}

Expand Down Expand Up @@ -247,12 +239,12 @@ public void testFailedAllocation() {
assertThat(unassignedPrimary.unassignedInfo().getMessage(), containsString("boom"));
// bumped up the max retry count, so canForceAllocatePrimary should return a YES decision
assertEquals(
Decision.YES,
Decision.Type.YES,
new MaxRetryAllocationDecider().canForceAllocatePrimary(
routingTable.index("idx").shard(0).shard(0),
null,
new RoutingAllocation(null, clusterState, null, null, 0)
)
newRoutingAllocation(clusterState)
).type()
);

// now we start the shard
Expand All @@ -279,13 +271,17 @@ public void testFailedAllocation() {
assertThat(unassignedPrimary.unassignedInfo().getMessage(), containsString("ZOOOMG"));
// Counter reset, so MaxRetryAllocationDecider#canForceAllocatePrimary should return a YES decision
assertEquals(
Decision.YES,
new MaxRetryAllocationDecider().canForceAllocatePrimary(
unassignedPrimary,
null,
new RoutingAllocation(null, clusterState, null, null, 0)
)
Decision.Type.YES,
new MaxRetryAllocationDecider().canForceAllocatePrimary(unassignedPrimary, null, newRoutingAllocation(clusterState)).type()
);
}

private RoutingAllocation newRoutingAllocation(ClusterState clusterState) {
final var routingAllocation = new RoutingAllocation(null, clusterState, null, null, 0);
if (randomBoolean()) {
routingAllocation.setDebugMode(randomFrom(RoutingAllocation.DebugMode.values()));
}
return routingAllocation;
}

}