1010import org .elasticsearch .common .Strings ;
1111import org .elasticsearch .common .io .stream .StreamInput ;
1212import org .elasticsearch .common .io .stream .StreamOutput ;
13+ import org .elasticsearch .common .settings .Settings ;
1314import org .elasticsearch .xcontent .ObjectParser ;
1415import org .elasticsearch .xcontent .XContentBuilder ;
1516import org .elasticsearch .xcontent .XContentParser ;
@@ -27,6 +28,10 @@ public class ReadOnlyAction implements LifecycleAction {
2728
2829 private static final ObjectParser <ReadOnlyAction , Void > PARSER = new ObjectParser <>(NAME , false , ReadOnlyAction ::new );
2930
31+ public static final String INDEXING_COMPLETE_STEP_NAME = "set-indexing-complete" ;
32+
33+ private static final Settings INDEXING_COMPLETE = Settings .builder ().put (LifecycleSettings .LIFECYCLE_INDEXING_COMPLETE , true ).build ();
34+
3035 public static ReadOnlyAction parse (XContentParser parser ) {
3136 return PARSER .apply (parser , null );
3237 }
@@ -60,6 +65,8 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
6065 StepKey checkNotWriteIndex = new StepKey (phase , NAME , CheckNotDataStreamWriteIndexStep .NAME );
6166 StepKey waitTimeSeriesEndTimePassesKey = new StepKey (phase , NAME , WaitUntilTimeSeriesEndTimePassesStep .NAME );
6267 StepKey readOnlyKey = new StepKey (phase , NAME , NAME );
68+ StepKey setIndexingCompleteStepKey = new StepKey (phase , NAME , INDEXING_COMPLETE_STEP_NAME );
69+
6370 CheckNotDataStreamWriteIndexStep checkNotWriteIndexStep = new CheckNotDataStreamWriteIndexStep (
6471 checkNotWriteIndex ,
6572 waitTimeSeriesEndTimePassesKey
@@ -69,8 +76,16 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
6976 readOnlyKey ,
7077 Instant ::now
7178 );
72- ReadOnlyStep readOnlyStep = new ReadOnlyStep (readOnlyKey , nextStepKey , client , true );
73- return List .of (checkNotWriteIndexStep , waitUntilTimeSeriesEndTimeStep , readOnlyStep );
79+ ReadOnlyStep readOnlyStep = new ReadOnlyStep (readOnlyKey , setIndexingCompleteStepKey , client , true );
80+
81+ UpdateSettingsStep setIndexingCompleteStep = new UpdateSettingsStep (
82+ setIndexingCompleteStepKey ,
83+ nextStepKey ,
84+ client ,
85+ INDEXING_COMPLETE
86+ );
87+
88+ return List .of (checkNotWriteIndexStep , waitUntilTimeSeriesEndTimeStep , readOnlyStep , setIndexingCompleteStep );
7489 }
7590
7691 @ Override
0 commit comments