diff --git a/docs/reference/ilm/actions/ilm-freeze.asciidoc b/docs/reference/ilm/actions/ilm-freeze.asciidoc index 51c26ec4e92b1..db413545c0910 100644 --- a/docs/reference/ilm/actions/ilm-freeze.asciidoc +++ b/docs/reference/ilm/actions/ilm-freeze.asciidoc @@ -6,10 +6,7 @@ Phases allowed: cold. <> an index. -IMPORTANT: Freezing an index closes the index and reopens it within the same API call. -This means that for a short time no primaries are allocated. -The cluster will go red until the primaries are allocated. -This limitation might be removed in the future. +deprecated[7.x,"The ILM Freeze action was deprecated in 7.x and will be treated as a no-op in 8.0+."] [[ilm-freeze-options]] ==== Options diff --git a/docs/reference/migration/migrate_8_0/ilm.asciidoc b/docs/reference/migration/migrate_8_0/ilm.asciidoc index b41947528c4ff..7c89db92965bd 100644 --- a/docs/reference/migration/migrate_8_0/ilm.asciidoc +++ b/docs/reference/migration/migrate_8_0/ilm.asciidoc @@ -38,4 +38,16 @@ renamed to `ilm` to match the package rename inside the {es} code. Update your workflow and applications to use the `ilm` package in place of `indexlifecycle`. ==== + +[[ilm-freeze-noop]] +.The ILM `freeze` action is now a no-op. +[%collapsible] +==== +*Details* + +The ILM freeze action is now a no-op and performs no action on the index, as the freeze API endpoint +has been removed in 8.0. + +*Impact* + +Update your ILM policies to remove the `freeze` action from the `cold` phase. +==== // end::notable-breaking-changes[] 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 7b203722284e5..e5f7d25ab8328 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 @@ -6,18 +6,15 @@ */ package org.elasticsearch.xpack.core.ilm; -import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.core.TimeValue; -import org.elasticsearch.protocol.xpack.frozen.FreezeRequest; -import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction; /** * Freezes an index. */ +@Deprecated // To be removed in 9.0 public class FreezeStep extends AsyncRetryDuringSnapshotActionStep { public static final String NAME = "freeze"; @@ -27,14 +24,8 @@ public FreezeStep(StepKey key, StepKey nextStepKey, Client client) { @Override public void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentState, ActionListener listener) { - getClient().admin().indices().execute(FreezeIndexAction.INSTANCE, - new FreezeRequest(indexMetadata.getIndex().getName()).masterNodeTimeout(TimeValue.MAX_VALUE), - ActionListener.wrap(response -> { - if (response.isAcknowledged() == false) { - throw new ElasticsearchException("freeze index request failed to be acknowledged"); - } - listener.onResponse(null); - }, listener::onFailure)); + // Deprecated in 7.x, the freeze action is a noop in 8.x, so immediately return here + listener.onResponse(null); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/FreezeStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/FreezeStepTests.java index 75ccf7be3d069..f8aaf2c2de09d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/FreezeStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/FreezeStepTests.java @@ -8,17 +8,8 @@ import org.elasticsearch.Version; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.support.PlainActionFuture; -import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.protocol.xpack.frozen.FreezeRequest; -import org.elasticsearch.protocol.xpack.frozen.FreezeResponse; -import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction; import org.elasticsearch.xpack.core.ilm.Step.StepKey; -import org.mockito.Mockito; - -import static org.hamcrest.Matchers.is; public class FreezeStepTests extends AbstractStepTestCase { @@ -62,59 +53,4 @@ private static IndexMetadata getIndexMetadata() { public void testIndexSurvives() { assertTrue(createRandomInstance().indexSurvives()); } - - public void testFreeze() throws Exception { - IndexMetadata indexMetadata = getIndexMetadata(); - - Mockito.doAnswer(invocation -> { - assertSame(invocation.getArguments()[0], FreezeIndexAction.INSTANCE); - FreezeRequest request = (FreezeRequest) invocation.getArguments()[1]; - @SuppressWarnings("unchecked") - ActionListener listener = (ActionListener) invocation.getArguments()[2]; - assertNotNull(request); - assertEquals(1, request.indices().length); - assertEquals(indexMetadata.getIndex().getName(), request.indices()[0]); - listener.onResponse(new FreezeResponse(true, true)); - return null; - }).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any()); - - FreezeStep step = createRandomInstance(); - PlainActionFuture.get(f -> step.performAction(indexMetadata, emptyClusterState(), null, f)); - - Mockito.verify(client, Mockito.only()).admin(); - Mockito.verify(adminClient, Mockito.only()).indices(); - Mockito.verify(indicesClient, Mockito.only()).execute(Mockito.any(), Mockito.any(), Mockito.any()); - } - - public void testExceptionThrown() { - IndexMetadata indexMetadata = getIndexMetadata(); - Exception exception = new RuntimeException(); - - Mockito.doAnswer(invocation -> { - @SuppressWarnings("unchecked") - ActionListener listener = (ActionListener) invocation.getArguments()[2]; - listener.onFailure(exception); - return null; - }).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any()); - - FreezeStep step = createRandomInstance(); - assertSame(exception, expectThrows(Exception.class, () -> PlainActionFuture.get( - f -> step.performAction(indexMetadata, emptyClusterState(), null, f)))); - } - - public void testNotAcknowledged() { - IndexMetadata indexMetadata = getIndexMetadata(); - - Mockito.doAnswer(invocation -> { - @SuppressWarnings("unchecked") - ActionListener listener = (ActionListener) invocation.getArguments()[2]; - listener.onResponse(new FreezeResponse(false, false)); - return null; - }).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any()); - - FreezeStep step = createRandomInstance(); - Exception e = expectThrows(Exception.class, - () -> PlainActionFuture.get(f -> step.performAction(indexMetadata, emptyClusterState(), null, f))); - assertThat(e.getMessage(), is("freeze index request failed to be acknowledged")); - } } diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java index aed9088a0e658..3bf04dc1edba3 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java @@ -15,7 +15,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xpack.core.ilm.CheckNotDataStreamWriteIndexStep; import org.elasticsearch.xpack.core.ilm.DeleteAction; @@ -187,9 +186,7 @@ public void testFreezeAction() throws Exception { TimeUnit.SECONDS); Map settings = getOnlyIndexSettings(client(), backingIndexName); - assertThat(settings.get(IndexMetadata.SETTING_BLOCKS_WRITE), equalTo("true")); - assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true")); - assertThat(settings.get("index.frozen"), equalTo("true")); + assertNull(settings.get("index.frozen")); } public void testForceMergeAction() throws Exception { diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java index 8db7dc0149a55..3df014888e136 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java @@ -25,7 +25,6 @@ import org.elasticsearch.core.CheckedRunnable; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.engine.EngineConfig; import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction; import org.elasticsearch.snapshots.SnapshotState; @@ -143,24 +142,17 @@ public void testRetryFailedDeleteAction() throws Exception { assertBusy(() -> assertFalse(indexExists(index))); } - public void testRetryFreezeDeleteAction() throws Exception { + public void testFreezeNoop() throws Exception { createNewSingletonPolicy(client(), policy, "cold", new FreezeAction()); createIndexWithSettings(client(), index, alias, 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((Integer) explainIndex(client(), index).get(FAILED_STEP_RETRY_COUNT_FIELD), greaterThanOrEqualTo(1)), + assertBusy(() -> assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey())), 30, TimeUnit.SECONDS); assertFalse(getOnlyIndexSettings(client(), 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(client(), index).get("index.frozen"), equalTo("true"))); } @@ -416,61 +408,6 @@ public void testForceMergeActionWithCompressionCodec() throws Exception { forceMergeActionWithCodec("best_compression"); } - public void testFreezeAction() throws Exception { - createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)); - createNewSingletonPolicy(client(), policy, "cold", new FreezeAction()); - updatePolicy(client(), index, policy); - assertBusy(() -> { - Map settings = getOnlyIndexSettings(client(), index); - assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey())); - assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true")); - assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true")); - assertThat(settings.get("index.frozen"), equalTo("true")); - }); - } - - public void testFreezeDuringSnapshot() throws Exception { - // Create the repository before taking the snapshot. - Request request = new Request("PUT", "/_snapshot/repo"); - request.setJsonEntity(Strings - .toString(JsonXContent.contentBuilder() - .startObject() - .field("type", "fs") - .startObject("settings") - .field("compress", randomBoolean()) - .field("location", System.getProperty("tests.path.repo")) - .field("max_snapshot_bytes_per_sec", "256b") - .endObject() - .endObject())); - assertOK(client().performRequest(request)); - // create delete policy - createNewSingletonPolicy(client(), policy, "cold", new FreezeAction(), TimeValue.timeValueMillis(0)); - // create index without policy - createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)); - // index document so snapshot actually does something - indexDocument(client(), index); - // start snapshot - request = new Request("PUT", "/_snapshot/repo/snapshot"); - request.addParameter("wait_for_completion", "false"); - request.setJsonEntity("{\"indices\": \"" + index + "\"}"); - assertOK(client().performRequest(request)); - // add policy and expect it to trigger delete immediately (while snapshot in progress) - updatePolicy(client(), index, policy); - // assert that the index froze - assertBusy(() -> { - Map settings = getOnlyIndexSettings(client(), index); - assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey())); - assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true")); - assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true")); - assertThat(settings.get("index.frozen"), equalTo("true")); - }, 2, TimeUnit.MINUTES); - // assert that snapshot is still in progress and clean up - assertThat(getSnapshotState(client(), "snapshot"), equalTo("SUCCESS")); - assertOK(client().performRequest(new Request("DELETE", "/_snapshot/repo/snapshot"))); - } - public void testSetPriority() throws Exception { createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.INDEX_PRIORITY_SETTING.getKey(), 100));