From c82f803f6cf3e593da77ec990cb64da517a21a10 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Thu, 20 Feb 2020 10:42:20 +0100 Subject: [PATCH] Make FreezeStep retryable (#52540) * Make FreezeStep retryable This change marks `FreezeStep` as retryable and adds test to make sure we can really run it again. * refactor tests --- .../xpack/core/ilm/FreezeStep.java | 5 +++++ .../ilm/TimeSeriesLifecycleActionsIT.java | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/FreezeStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/FreezeStep.java index 4b9c9a24d4caa..3b67e5bdc17d3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/FreezeStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/FreezeStep.java @@ -28,4 +28,9 @@ public void performDuringNoSnapshot(IndexMetaData indexMetaData, ClusterState cu new FreezeRequest(indexMetaData.getIndex().getName()).masterNodeTimeout(getMasterTimeout(currentState)), ActionListener.wrap(response -> listener.onResponse(true), listener::onFailure)); } + + @Override + public boolean isRetryable() { + return true; + } } diff --git a/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java index 6ad58acf4abd4..db71768a9b4f0 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java @@ -32,6 +32,7 @@ import org.elasticsearch.xpack.core.ilm.ErrorStep; import org.elasticsearch.xpack.core.ilm.ForceMergeAction; import org.elasticsearch.xpack.core.ilm.FreezeAction; +import org.elasticsearch.xpack.core.ilm.FreezeStep; import org.elasticsearch.xpack.core.ilm.InitializePolicyContextStep; import org.elasticsearch.xpack.core.ilm.LifecycleAction; import org.elasticsearch.xpack.core.ilm.LifecyclePolicy; @@ -228,6 +229,25 @@ public void testRetryFailedDeleteAction() throws Exception { assertBusy(() -> assertFalse(indexExists(index))); } + public void testRetryFreezeDeleteAction() throws Exception { + createNewSingletonPolicy("cold", new FreezeAction()); + + createIndexWithSettings(index, Settings.builder() + .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) + .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) + .put(IndexMetaData.SETTING_READ_ONLY, true) + .put("index.lifecycle.name", policy)); + + assertBusy(() -> assertThat(getFailedStepForIndex(index), equalTo(FreezeStep.NAME))); + assertFalse(getOnlyIndexSettings(index).containsKey("index.frozen")); + + Request request = new Request("PUT", index + "/_settings"); + request.setJsonEntity("{\"index.blocks.read_only\":false}"); + assertOK(client().performRequest(request)); + + assertBusy(() -> assertThat(getOnlyIndexSettings(index).get("index.frozen"), equalTo("true"))); + } + public void testRetryFailedShrinkAction() throws Exception { int numShards = 4; int divisor = randomFrom(2, 4);