Skip to content

Commit e45b2ef

Browse files
committed
[ILM] Fix TSDS unfollow timing with WaitUntilTimeSeriesEndTimePassesStep
1 parent b977b04 commit e45b2ef

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowAction.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
1818

1919
import java.io.IOException;
20+
import java.time.Instant;
2021
import java.util.List;
2122
import java.util.Map;
2223

@@ -45,6 +46,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
4546
StepKey preUnfollowKey = new StepKey(phase, NAME, CONDITIONAL_UNFOLLOW_STEP);
4647
StepKey indexingComplete = new StepKey(phase, NAME, WaitForIndexingCompleteStep.NAME);
4748
StepKey waitForFollowShardTasks = new StepKey(phase, NAME, WaitForFollowShardTasksStep.NAME);
49+
StepKey waitUntilTimeSeriesEndTimePassesStep = new StepKey(phase, NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
4850
StepKey pauseFollowerIndex = new StepKey(phase, NAME, PauseFollowerIndexStep.NAME);
4951
StepKey closeFollowerIndex = new StepKey(phase, NAME, CloseFollowerIndexStep.NAME);
5052
StepKey unfollowFollowerIndex = new StepKey(phase, NAME, UnfollowFollowerIndexStep.NAME);
@@ -60,13 +62,22 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
6062
return customIndexMetadata == null;
6163
});
6264
WaitForIndexingCompleteStep step1 = new WaitForIndexingCompleteStep(indexingComplete, waitForFollowShardTasks);
63-
WaitForFollowShardTasksStep step2 = new WaitForFollowShardTasksStep(waitForFollowShardTasks, pauseFollowerIndex, client);
64-
PauseFollowerIndexStep step3 = new PauseFollowerIndexStep(pauseFollowerIndex, closeFollowerIndex, client);
65-
CloseFollowerIndexStep step4 = new CloseFollowerIndexStep(closeFollowerIndex, unfollowFollowerIndex, client);
66-
UnfollowFollowerIndexStep step5 = new UnfollowFollowerIndexStep(unfollowFollowerIndex, openFollowerIndex, client);
67-
OpenIndexStep step6 = new OpenIndexStep(openFollowerIndex, waitForYellowStep, client);
68-
WaitForIndexColorStep step7 = new WaitForIndexColorStep(waitForYellowStep, nextStepKey, ClusterHealthStatus.YELLOW);
69-
return List.of(conditionalSkipUnfollowStep, step1, step2, step3, step4, step5, step6, step7);
65+
WaitForFollowShardTasksStep step2 = new WaitForFollowShardTasksStep(
66+
waitForFollowShardTasks,
67+
waitUntilTimeSeriesEndTimePassesStep,
68+
client
69+
);
70+
WaitUntilTimeSeriesEndTimePassesStep step3 = new WaitUntilTimeSeriesEndTimePassesStep(
71+
waitUntilTimeSeriesEndTimePassesStep,
72+
pauseFollowerIndex,
73+
Instant::now
74+
);
75+
PauseFollowerIndexStep step4 = new PauseFollowerIndexStep(pauseFollowerIndex, closeFollowerIndex, client);
76+
CloseFollowerIndexStep step5 = new CloseFollowerIndexStep(closeFollowerIndex, unfollowFollowerIndex, client);
77+
UnfollowFollowerIndexStep step6 = new UnfollowFollowerIndexStep(unfollowFollowerIndex, openFollowerIndex, client);
78+
OpenIndexStep step7 = new OpenIndexStep(openFollowerIndex, waitForYellowStep, client);
79+
WaitForIndexColorStep step8 = new WaitForIndexColorStep(waitForYellowStep, nextStepKey, ClusterHealthStatus.YELLOW);
80+
return List.of(conditionalSkipUnfollowStep, step1, step2, step3, step4, step5, step6, step7, step8);
7081
}
7182

7283
@Override

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/UnfollowActionTests.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ public void testToSteps() {
5151
);
5252
List<Step> steps = action.toSteps(null, phase, nextStepKey);
5353
assertThat(steps, notNullValue());
54-
assertThat(steps.size(), equalTo(8));
54+
assertThat(steps.size(), equalTo(9));
5555

5656
StepKey expectedFirstStepKey = new StepKey(phase, UnfollowAction.NAME, UnfollowAction.CONDITIONAL_UNFOLLOW_STEP);
5757
StepKey expectedSecondStepKey = new StepKey(phase, UnfollowAction.NAME, WaitForIndexingCompleteStep.NAME);
5858
StepKey expectedThirdStepKey = new StepKey(phase, UnfollowAction.NAME, WaitForFollowShardTasksStep.NAME);
59-
StepKey expectedFourthStepKey = new StepKey(phase, UnfollowAction.NAME, PauseFollowerIndexStep.NAME);
60-
StepKey expectedFifthStepKey = new StepKey(phase, UnfollowAction.NAME, CloseFollowerIndexStep.NAME);
61-
StepKey expectedSixthStepKey = new StepKey(phase, UnfollowAction.NAME, UnfollowFollowerIndexStep.NAME);
62-
StepKey expectedSeventhStepKey = new StepKey(phase, UnfollowAction.NAME, OPEN_FOLLOWER_INDEX_STEP_NAME);
63-
StepKey expectedEighthStepKey = new StepKey(phase, UnfollowAction.NAME, WaitForIndexColorStep.NAME);
59+
StepKey expectedFourthStepKey = new StepKey(phase, UnfollowAction.NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
60+
StepKey expectedFifthStepKey = new StepKey(phase, UnfollowAction.NAME, PauseFollowerIndexStep.NAME);
61+
StepKey expectedSixthStepKey = new StepKey(phase, UnfollowAction.NAME, CloseFollowerIndexStep.NAME);
62+
StepKey expectedSeventhStepKey = new StepKey(phase, UnfollowAction.NAME, UnfollowFollowerIndexStep.NAME);
63+
StepKey expectedEighthStepKey = new StepKey(phase, UnfollowAction.NAME, OPEN_FOLLOWER_INDEX_STEP_NAME);
64+
StepKey expectedNinthStepKey = new StepKey(phase, UnfollowAction.NAME, WaitForIndexColorStep.NAME);
6465

6566
BranchingStep firstStep = (BranchingStep) steps.get(0);
6667
assertThat(firstStep.getKey(), equalTo(expectedFirstStepKey));
@@ -73,26 +74,30 @@ public void testToSteps() {
7374
assertThat(thirdStep.getKey(), equalTo(expectedThirdStepKey));
7475
assertThat(thirdStep.getNextStepKey(), equalTo(expectedFourthStepKey));
7576

76-
PauseFollowerIndexStep fourthStep = (PauseFollowerIndexStep) steps.get(3);
77+
WaitUntilTimeSeriesEndTimePassesStep fourthStep = (WaitUntilTimeSeriesEndTimePassesStep) steps.get(3);
7778
assertThat(fourthStep.getKey(), equalTo(expectedFourthStepKey));
7879
assertThat(fourthStep.getNextStepKey(), equalTo(expectedFifthStepKey));
7980

80-
CloseFollowerIndexStep fifthStep = (CloseFollowerIndexStep) steps.get(4);
81+
PauseFollowerIndexStep fifthStep = (PauseFollowerIndexStep) steps.get(4);
8182
assertThat(fifthStep.getKey(), equalTo(expectedFifthStepKey));
8283
assertThat(fifthStep.getNextStepKey(), equalTo(expectedSixthStepKey));
8384

84-
UnfollowFollowerIndexStep sixthStep = (UnfollowFollowerIndexStep) steps.get(5);
85+
CloseFollowerIndexStep sixthStep = (CloseFollowerIndexStep) steps.get(5);
8586
assertThat(sixthStep.getKey(), equalTo(expectedSixthStepKey));
8687
assertThat(sixthStep.getNextStepKey(), equalTo(expectedSeventhStepKey));
8788

88-
OpenIndexStep seventhStep = (OpenIndexStep) steps.get(6);
89+
UnfollowFollowerIndexStep seventhStep = (UnfollowFollowerIndexStep) steps.get(6);
8990
assertThat(seventhStep.getKey(), equalTo(expectedSeventhStepKey));
9091
assertThat(seventhStep.getNextStepKey(), equalTo(expectedEighthStepKey));
9192

92-
WaitForIndexColorStep eighthStep = (WaitForIndexColorStep) steps.get(7);
93-
assertThat(eighthStep.getColor(), is(ClusterHealthStatus.YELLOW));
93+
OpenIndexStep eighthStep = (OpenIndexStep) steps.get(7);
9494
assertThat(eighthStep.getKey(), equalTo(expectedEighthStepKey));
95-
assertThat(eighthStep.getNextStepKey(), equalTo(nextStepKey));
95+
assertThat(eighthStep.getNextStepKey(), equalTo(expectedNinthStepKey));
96+
97+
WaitForIndexColorStep ninth = (WaitForIndexColorStep) steps.get(8);
98+
assertThat(ninth.getColor(), is(ClusterHealthStatus.YELLOW));
99+
assertThat(ninth.getKey(), equalTo(expectedNinthStepKey));
100+
assertThat(ninth.getNextStepKey(), equalTo(nextStepKey));
96101
}
97102

98103
@Override

0 commit comments

Comments
 (0)