Skip to content

Commit bf8586e

Browse files
authored
Make DeleteStep retryable (#52494)
* Make DeleteStep retryable This change marks `DeleteStep` as retryable and adds test to make sure we really can invoke it again. * Fix unused import * revert unneeded changes * test reworked
1 parent 3c21eca commit bf8586e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ public void performDuringNoSnapshot(IndexMetaData indexMetaData, ClusterState cu
3232
public boolean indexSurvives() {
3333
return false;
3434
}
35+
36+
@Override
37+
public boolean isRetryable() {
38+
return true;
39+
}
3540
}

x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.test.rest.ESRestTestCase;
2929
import org.elasticsearch.xpack.core.ilm.AllocateAction;
3030
import org.elasticsearch.xpack.core.ilm.DeleteAction;
31+
import org.elasticsearch.xpack.core.ilm.DeleteStep;
3132
import org.elasticsearch.xpack.core.ilm.ErrorStep;
3233
import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
3334
import org.elasticsearch.xpack.core.ilm.FreezeAction;
@@ -206,6 +207,27 @@ public void testMoveToRolloverStep() throws Exception {
206207
assertBusy(() -> assertFalse(indexExists(shrunkenOriginalIndex)));
207208
}
208209

210+
public void testRetryFailedDeleteAction() throws Exception {
211+
createIndexWithSettings(index, Settings.builder()
212+
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
213+
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
214+
.put(IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE, false));
215+
216+
createNewSingletonPolicy("delete", new DeleteAction());
217+
218+
Request request = new Request("PUT", index + "/_settings");
219+
request.setJsonEntity("{\"index.blocks.read_only\": true, \"index.lifecycle.name\": \"" + policy + "\"}");
220+
assertOK(client().performRequest(request));
221+
222+
assertBusy(() -> assertThat(getFailedStepForIndex(index), equalTo(DeleteStep.NAME)));
223+
assertTrue(indexExists(index));
224+
225+
request.setJsonEntity("{\"index.blocks.read_only\":false}");
226+
assertOK(client().performRequest(request));
227+
228+
assertBusy(() -> assertFalse(indexExists(index)));
229+
}
230+
209231
public void testRetryFailedShrinkAction() throws Exception {
210232
int numShards = 4;
211233
int divisor = randomFrom(2, 4);

0 commit comments

Comments
 (0)