Skip to content

Enhancement: ILM sets indexing_complete to true from ReadOnly action #129945

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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/129945.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 129945
summary: "Enhancement: ILM sets `indexing_complete` to true from `ReadOnly` action"
area: ILM+SLM
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.ObjectParser;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;
Expand All @@ -27,6 +28,10 @@ public class ReadOnlyAction implements LifecycleAction {

private static final ObjectParser<ReadOnlyAction, Void> PARSER = new ObjectParser<>(NAME, false, ReadOnlyAction::new);

public static final String INDEXING_COMPLETE_STEP_NAME = "set-indexing-complete";

private static final Settings INDEXING_COMPLETE = Settings.builder().put(LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE, true).build();

public static ReadOnlyAction parse(XContentParser parser) {
return PARSER.apply(parser, null);
}
Expand Down Expand Up @@ -60,6 +65,8 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
StepKey checkNotWriteIndex = new StepKey(phase, NAME, CheckNotDataStreamWriteIndexStep.NAME);
StepKey waitTimeSeriesEndTimePassesKey = new StepKey(phase, NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
StepKey readOnlyKey = new StepKey(phase, NAME, NAME);
StepKey setIndexingCompleteStepKey = new StepKey(phase, NAME, INDEXING_COMPLETE_STEP_NAME);

CheckNotDataStreamWriteIndexStep checkNotWriteIndexStep = new CheckNotDataStreamWriteIndexStep(
checkNotWriteIndex,
waitTimeSeriesEndTimePassesKey
Expand All @@ -69,8 +76,16 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
readOnlyKey,
Instant::now
);
ReadOnlyStep readOnlyStep = new ReadOnlyStep(readOnlyKey, nextStepKey, client, true);
return List.of(checkNotWriteIndexStep, waitUntilTimeSeriesEndTimeStep, readOnlyStep);
ReadOnlyStep readOnlyStep = new ReadOnlyStep(readOnlyKey, setIndexingCompleteStepKey, client, true);

UpdateSettingsStep setIndexingCompleteStep = new UpdateSettingsStep(
setIndexingCompleteStepKey,
nextStepKey,
client,
INDEXING_COMPLETE
);

return List.of(checkNotWriteIndexStep, waitUntilTimeSeriesEndTimeStep, readOnlyStep, setIndexingCompleteStep);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.List;

import static org.elasticsearch.xpack.core.ilm.ReadOnlyAction.INDEXING_COMPLETE_STEP_NAME;
import static org.hamcrest.Matchers.equalTo;

public class ReadOnlyActionTests extends AbstractActionTestCase<ReadOnlyAction> {
Expand Down Expand Up @@ -46,13 +47,16 @@ public void testToSteps() {
);
List<Step> steps = action.toSteps(null, phase, nextStepKey);
assertNotNull(steps);
assertEquals(3, steps.size());
assertEquals(4, steps.size());
StepKey expectedFirstStepKey = new StepKey(phase, ReadOnlyAction.NAME, CheckNotDataStreamWriteIndexStep.NAME);
StepKey expectedSecondStepKey = new StepKey(phase, ReadOnlyAction.NAME, WaitUntilTimeSeriesEndTimePassesStep.NAME);
StepKey expectedThirdStepKey = new StepKey(phase, ReadOnlyAction.NAME, ReadOnlyAction.NAME);
StepKey expectedFourthStepKey = new StepKey(phase, ReadOnlyAction.NAME, INDEXING_COMPLETE_STEP_NAME);

CheckNotDataStreamWriteIndexStep firstStep = (CheckNotDataStreamWriteIndexStep) steps.get(0);
WaitUntilTimeSeriesEndTimePassesStep secondStep = (WaitUntilTimeSeriesEndTimePassesStep) steps.get(1);
ReadOnlyStep thirdStep = (ReadOnlyStep) steps.get(2);
UpdateSettingsStep fourthStep = (UpdateSettingsStep) steps.get(3);

assertThat(firstStep.getKey(), equalTo(expectedFirstStepKey));
assertThat(firstStep.getNextStepKey(), equalTo(expectedSecondStepKey));
Expand All @@ -61,7 +65,10 @@ public void testToSteps() {
assertThat(secondStep.getNextStepKey(), equalTo(expectedThirdStepKey));

assertThat(thirdStep.getKey(), equalTo(expectedThirdStepKey));
assertThat(thirdStep.getNextStepKey(), equalTo(nextStepKey));
assertThat(thirdStep.getNextStepKey(), equalTo(expectedFourthStepKey));

assertThat(fourthStep.getKey(), equalTo(expectedFourthStepKey));
assertThat(fourthStep.getNextStepKey(), equalTo(nextStepKey));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void testReadOnly() throws Exception {
assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep(phaseName).getKey()));
assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_METADATA_SETTING.getKey()), nullValue());
assertThat(settings.get(LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE_SETTING.getKey()), equalTo("true"));
});
}

Expand Down
Loading