Skip to content

[8.x] Fix equality bug in WaitForIndexColorStep (#126605) #126619

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/126605.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 126605
summary: Fix equality bug in `WaitForIndexColorStep`
area: ILM+SLM
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ BiFunction<String, LifecycleExecutionState, String> getIndexNameSupplier() {

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), this.color, this.indexNameSupplier);
return Objects.hash(super.hashCode(), this.color);
}

@Override
Expand All @@ -77,9 +77,7 @@ public boolean equals(Object obj) {
return false;
}
WaitForIndexColorStep other = (WaitForIndexColorStep) obj;
return super.equals(obj)
&& Objects.equals(this.color, other.color)
&& Objects.equals(this.indexNameSupplier, other.indexNameSupplier);
return super.equals(obj) && Objects.equals(this.color, other.color);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ public void testSearchableSnapshotAction() throws Exception {
}
}, 30, TimeUnit.SECONDS));

assertBusy(() -> {
triggerStateChange();
assertThat(explainIndex(client(), restoredIndexName).get("step"), is(PhaseCompleteStep.NAME));
}, 30, TimeUnit.SECONDS);
assertBusy(
() -> { assertThat(explainIndex(client(), restoredIndexName).get("step"), is(PhaseCompleteStep.NAME)); },
30,
TimeUnit.SECONDS
);
}

public void testSearchableSnapshotForceMergesIndexToOneSegment() throws Exception {
Expand Down Expand Up @@ -173,10 +174,11 @@ public void testSearchableSnapshotForceMergesIndexToOneSegment() throws Exceptio
}
}, 60, TimeUnit.SECONDS));

assertBusy(() -> {
triggerStateChange();
assertThat(explainIndex(client(), restoredIndexName).get("step"), is(PhaseCompleteStep.NAME));
}, 30, TimeUnit.SECONDS);
assertBusy(
() -> { assertThat(explainIndex(client(), restoredIndexName).get("step"), is(PhaseCompleteStep.NAME)); },
30,
TimeUnit.SECONDS
);
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -314,7 +316,6 @@ public void testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped() throws
}, 30, TimeUnit.SECONDS));

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), restoredIndexName);
assertThat(stepKeyForIndex.phase(), is("hot"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand All @@ -337,7 +338,6 @@ public void testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped() throws
// even though the index is now mounted as a searchable snapshot, the actions that can't operate on it should
// skip and ILM should not be blocked (not should the managed index move into the ERROR step)
assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), restoredIndexName);
assertThat(stepKeyForIndex.phase(), is("cold"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -392,7 +392,6 @@ public void testRestoredIndexManagedByLocalPolicySkipsIllegalActions() throws Ex
}, 30, TimeUnit.SECONDS));

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("hot"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -483,7 +482,6 @@ public void testIdenticalSearchableSnapshotActionIsNoop() throws Exception {
}, 30, TimeUnit.SECONDS);

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("cold"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -545,7 +543,6 @@ public void testConvertingSearchableSnapshotFromFullToPartial() throws Exception
}, 30, TimeUnit.SECONDS);

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("frozen"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -628,7 +625,6 @@ public void testResumingSearchableSnapshotFromFullToPartial() throws Exception {
}, 30, TimeUnit.SECONDS);

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), fullMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("cold"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand All @@ -649,7 +645,6 @@ public void testResumingSearchableSnapshotFromFullToPartial() throws Exception {
}, 30, TimeUnit.SECONDS);

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), partiallyMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("frozen"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -739,7 +734,6 @@ public void testResumingSearchableSnapshotFromPartialToFull() throws Exception {
}, 30, TimeUnit.SECONDS);

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), partialMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("frozen"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand All @@ -760,7 +754,6 @@ public void testResumingSearchableSnapshotFromPartialToFull() throws Exception {
}, 30, TimeUnit.SECONDS);

assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), restoredPartiallyMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("cold"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -920,10 +913,11 @@ public void testSearchableSnapshotInvokesAsyncActionOnNewIndex() throws Exceptio
}
}, 30, TimeUnit.SECONDS));

assertBusy(() -> {
triggerStateChange();
assertThat(explainIndex(client(), restoredIndexName).get("step"), is(PhaseCompleteStep.NAME));
}, 30, TimeUnit.SECONDS);
assertBusy(
() -> { assertThat(explainIndex(client(), restoredIndexName).get("step"), is(PhaseCompleteStep.NAME)); },
30,
TimeUnit.SECONDS
);
}

public void testSearchableSnapshotTotalShardsPerNode() throws Exception {
Expand Down Expand Up @@ -964,7 +958,6 @@ public void testSearchableSnapshotTotalShardsPerNode() throws Exception {
assertTrue(indexExists(searchableSnapMountedIndexName));
}, 30, TimeUnit.SECONDS);
assertBusy(() -> {
triggerStateChange();
Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
assertThat(stepKeyForIndex.phase(), is("frozen"));
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
Expand Down Expand Up @@ -1028,7 +1021,6 @@ public void testSearchableSnapshotReplicateFor() throws Exception {

// check that the index is in the expected step and has the expected step_info.message
assertBusy(() -> {
triggerStateChange();
Map<String, Object> explainResponse = explainIndex(client(), restoredIndexName);
assertThat(explainResponse.get("step"), is(WaitUntilReplicateForTimePassesStep.NAME));
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -1066,7 +1058,6 @@ public void testSearchableSnapshotReplicateFor() throws Exception {

// check that the index has progressed because enough time has passed now that the policy is different
assertBusy(() -> {
triggerStateChange();
Map<String, Object> explainResponse = explainIndex(client(), restoredIndexName);
assertThat(explainResponse.get("phase"), is("cold"));
assertThat(explainResponse.get("step"), is(PhaseCompleteStep.NAME));
Expand All @@ -1080,13 +1071,4 @@ public void testSearchableSnapshotReplicateFor() throws Exception {
assertThat(numberOfReplicas, is(0));
}
}

/**
* Cause a bit of cluster activity using an empty reroute call in case the `wait-for-index-colour` ILM step missed the
* notification that partial-index is now GREEN.
*/
private void triggerStateChange() throws IOException {
Request rerouteRequest = new Request("POST", "/_cluster/reroute?metric=none");
client().performRequest(rerouteRequest);
}
}