Skip to content

Commit 35def94

Browse files
Make the ILM freeze action a no-op (#77158)
* Make the ILM `freeze` action a no-op This changes the ILM `freeze` action to not actually freeze the index, instead performing no operation. Relates to #70192 * zoop -> noop in documentation anchor Co-authored-by: Elastic Machine <[email protected]>
1 parent 225ae14 commit 35def94

File tree

6 files changed

+19
-149
lines changed

6 files changed

+19
-149
lines changed

docs/reference/ilm/actions/ilm-freeze.asciidoc

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ Phases allowed: cold.
66

77
<<freeze-index-api, Freezes>> an index.
88

9-
IMPORTANT: Freezing an index closes the index and reopens it within the same API call.
10-
This means that for a short time no primaries are allocated.
11-
The cluster will go red until the primaries are allocated.
12-
This limitation might be removed in the future.
9+
deprecated[7.x,"The ILM Freeze action was deprecated in 7.x and will be treated as a no-op in 8.0+."]
1310

1411
[[ilm-freeze-options]]
1512
==== Options

docs/reference/migration/migrate_8_0/ilm.asciidoc

+12
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,16 @@ renamed to `ilm` to match the package rename inside the {es} code.
3838
Update your workflow and applications to use the `ilm` package in place of
3939
`indexlifecycle`.
4040
====
41+
42+
[[ilm-freeze-noop]]
43+
.The ILM `freeze` action is now a no-op.
44+
[%collapsible]
45+
====
46+
*Details* +
47+
The ILM freeze action is now a no-op and performs no action on the index, as the freeze API endpoint
48+
has been removed in 8.0.
49+
50+
*Impact* +
51+
Update your ILM policies to remove the `freeze` action from the `cold` phase.
52+
====
4153
// end::notable-breaking-changes[]

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

+3-12
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
*/
77
package org.elasticsearch.xpack.core.ilm;
88

9-
import org.elasticsearch.ElasticsearchException;
109
import org.elasticsearch.action.ActionListener;
1110
import org.elasticsearch.client.Client;
1211
import org.elasticsearch.cluster.ClusterState;
1312
import org.elasticsearch.cluster.metadata.IndexMetadata;
14-
import org.elasticsearch.core.TimeValue;
15-
import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
16-
import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction;
1713

1814
/**
1915
* Freezes an index.
2016
*/
17+
@Deprecated // To be removed in 9.0
2118
public class FreezeStep extends AsyncRetryDuringSnapshotActionStep {
2219
public static final String NAME = "freeze";
2320

@@ -27,14 +24,8 @@ public FreezeStep(StepKey key, StepKey nextStepKey, Client client) {
2724

2825
@Override
2926
public void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentState, ActionListener<Void> listener) {
30-
getClient().admin().indices().execute(FreezeIndexAction.INSTANCE,
31-
new FreezeRequest(indexMetadata.getIndex().getName()).masterNodeTimeout(TimeValue.MAX_VALUE),
32-
ActionListener.wrap(response -> {
33-
if (response.isAcknowledged() == false) {
34-
throw new ElasticsearchException("freeze index request failed to be acknowledged");
35-
}
36-
listener.onResponse(null);
37-
}, listener::onFailure));
27+
// Deprecated in 7.x, the freeze action is a noop in 8.x, so immediately return here
28+
listener.onResponse(null);
3829
}
3930

4031
@Override

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/FreezeStepTests.java

-64
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@
88

99

1010
import org.elasticsearch.Version;
11-
import org.elasticsearch.action.ActionListener;
12-
import org.elasticsearch.action.support.PlainActionFuture;
13-
import org.elasticsearch.action.support.master.AcknowledgedResponse;
1411
import org.elasticsearch.cluster.metadata.IndexMetadata;
15-
import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
16-
import org.elasticsearch.protocol.xpack.frozen.FreezeResponse;
17-
import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction;
1812
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
19-
import org.mockito.Mockito;
20-
21-
import static org.hamcrest.Matchers.is;
2213

2314
public class FreezeStepTests extends AbstractStepTestCase<FreezeStep> {
2415

@@ -62,59 +53,4 @@ private static IndexMetadata getIndexMetadata() {
6253
public void testIndexSurvives() {
6354
assertTrue(createRandomInstance().indexSurvives());
6455
}
65-
66-
public void testFreeze() throws Exception {
67-
IndexMetadata indexMetadata = getIndexMetadata();
68-
69-
Mockito.doAnswer(invocation -> {
70-
assertSame(invocation.getArguments()[0], FreezeIndexAction.INSTANCE);
71-
FreezeRequest request = (FreezeRequest) invocation.getArguments()[1];
72-
@SuppressWarnings("unchecked")
73-
ActionListener<AcknowledgedResponse> listener = (ActionListener<AcknowledgedResponse>) invocation.getArguments()[2];
74-
assertNotNull(request);
75-
assertEquals(1, request.indices().length);
76-
assertEquals(indexMetadata.getIndex().getName(), request.indices()[0]);
77-
listener.onResponse(new FreezeResponse(true, true));
78-
return null;
79-
}).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any());
80-
81-
FreezeStep step = createRandomInstance();
82-
PlainActionFuture.<Void, Exception>get(f -> step.performAction(indexMetadata, emptyClusterState(), null, f));
83-
84-
Mockito.verify(client, Mockito.only()).admin();
85-
Mockito.verify(adminClient, Mockito.only()).indices();
86-
Mockito.verify(indicesClient, Mockito.only()).execute(Mockito.any(), Mockito.any(), Mockito.any());
87-
}
88-
89-
public void testExceptionThrown() {
90-
IndexMetadata indexMetadata = getIndexMetadata();
91-
Exception exception = new RuntimeException();
92-
93-
Mockito.doAnswer(invocation -> {
94-
@SuppressWarnings("unchecked")
95-
ActionListener<AcknowledgedResponse> listener = (ActionListener<AcknowledgedResponse>) invocation.getArguments()[2];
96-
listener.onFailure(exception);
97-
return null;
98-
}).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any());
99-
100-
FreezeStep step = createRandomInstance();
101-
assertSame(exception, expectThrows(Exception.class, () -> PlainActionFuture.<Void, Exception>get(
102-
f -> step.performAction(indexMetadata, emptyClusterState(), null, f))));
103-
}
104-
105-
public void testNotAcknowledged() {
106-
IndexMetadata indexMetadata = getIndexMetadata();
107-
108-
Mockito.doAnswer(invocation -> {
109-
@SuppressWarnings("unchecked")
110-
ActionListener<AcknowledgedResponse> listener = (ActionListener<AcknowledgedResponse>) invocation.getArguments()[2];
111-
listener.onResponse(new FreezeResponse(false, false));
112-
return null;
113-
}).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any());
114-
115-
FreezeStep step = createRandomInstance();
116-
Exception e = expectThrows(Exception.class,
117-
() -> PlainActionFuture.<Void, Exception>get(f -> step.performAction(indexMetadata, emptyClusterState(), null, f)));
118-
assertThat(e.getMessage(), is("freeze index request failed to be acknowledged"));
119-
}
12056
}

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.elasticsearch.common.settings.Settings;
1616
import org.elasticsearch.common.xcontent.XContentHelper;
1717
import org.elasticsearch.common.xcontent.XContentType;
18-
import org.elasticsearch.index.IndexSettings;
1918
import org.elasticsearch.test.rest.ESRestTestCase;
2019
import org.elasticsearch.xpack.core.ilm.CheckNotDataStreamWriteIndexStep;
2120
import org.elasticsearch.xpack.core.ilm.DeleteAction;
@@ -187,9 +186,7 @@ public void testFreezeAction() throws Exception {
187186
TimeUnit.SECONDS);
188187

189188
Map<String, Object> settings = getOnlyIndexSettings(client(), backingIndexName);
190-
assertThat(settings.get(IndexMetadata.SETTING_BLOCKS_WRITE), equalTo("true"));
191-
assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true"));
192-
assertThat(settings.get("index.frozen"), equalTo("true"));
189+
assertNull(settings.get("index.frozen"));
193190
}
194191

195192
public void testForceMergeAction() throws Exception {

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

+2-65
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.elasticsearch.core.CheckedRunnable;
2626
import org.elasticsearch.core.Nullable;
2727
import org.elasticsearch.core.TimeValue;
28-
import org.elasticsearch.index.IndexSettings;
2928
import org.elasticsearch.index.engine.EngineConfig;
3029
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
3130
import org.elasticsearch.snapshots.SnapshotState;
@@ -143,24 +142,17 @@ public void testRetryFailedDeleteAction() throws Exception {
143142
assertBusy(() -> assertFalse(indexExists(index)));
144143
}
145144

146-
public void testRetryFreezeDeleteAction() throws Exception {
145+
public void testFreezeNoop() throws Exception {
147146
createNewSingletonPolicy(client(), policy, "cold", new FreezeAction());
148147

149148
createIndexWithSettings(client(), index, alias, Settings.builder()
150149
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
151150
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
152-
.put(IndexMetadata.SETTING_READ_ONLY, true)
153151
.put("index.lifecycle.name", policy));
154152

155-
assertBusy(() -> assertThat((Integer) explainIndex(client(), index).get(FAILED_STEP_RETRY_COUNT_FIELD), greaterThanOrEqualTo(1)),
153+
assertBusy(() -> assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey())),
156154
30, TimeUnit.SECONDS);
157155
assertFalse(getOnlyIndexSettings(client(), index).containsKey("index.frozen"));
158-
159-
Request request = new Request("PUT", index + "/_settings");
160-
request.setJsonEntity("{\"index.blocks.read_only\":false}");
161-
assertOK(client().performRequest(request));
162-
163-
assertBusy(() -> assertThat(getOnlyIndexSettings(client(), index).get("index.frozen"), equalTo("true")));
164156
}
165157

166158

@@ -416,61 +408,6 @@ public void testForceMergeActionWithCompressionCodec() throws Exception {
416408
forceMergeActionWithCodec("best_compression");
417409
}
418410

419-
public void testFreezeAction() throws Exception {
420-
createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
421-
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0));
422-
createNewSingletonPolicy(client(), policy, "cold", new FreezeAction());
423-
updatePolicy(client(), index, policy);
424-
assertBusy(() -> {
425-
Map<String, Object> settings = getOnlyIndexSettings(client(), index);
426-
assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey()));
427-
assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
428-
assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true"));
429-
assertThat(settings.get("index.frozen"), equalTo("true"));
430-
});
431-
}
432-
433-
public void testFreezeDuringSnapshot() throws Exception {
434-
// Create the repository before taking the snapshot.
435-
Request request = new Request("PUT", "/_snapshot/repo");
436-
request.setJsonEntity(Strings
437-
.toString(JsonXContent.contentBuilder()
438-
.startObject()
439-
.field("type", "fs")
440-
.startObject("settings")
441-
.field("compress", randomBoolean())
442-
.field("location", System.getProperty("tests.path.repo"))
443-
.field("max_snapshot_bytes_per_sec", "256b")
444-
.endObject()
445-
.endObject()));
446-
assertOK(client().performRequest(request));
447-
// create delete policy
448-
createNewSingletonPolicy(client(), policy, "cold", new FreezeAction(), TimeValue.timeValueMillis(0));
449-
// create index without policy
450-
createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
451-
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0));
452-
// index document so snapshot actually does something
453-
indexDocument(client(), index);
454-
// start snapshot
455-
request = new Request("PUT", "/_snapshot/repo/snapshot");
456-
request.addParameter("wait_for_completion", "false");
457-
request.setJsonEntity("{\"indices\": \"" + index + "\"}");
458-
assertOK(client().performRequest(request));
459-
// add policy and expect it to trigger delete immediately (while snapshot in progress)
460-
updatePolicy(client(), index, policy);
461-
// assert that the index froze
462-
assertBusy(() -> {
463-
Map<String, Object> settings = getOnlyIndexSettings(client(), index);
464-
assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey()));
465-
assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
466-
assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true"));
467-
assertThat(settings.get("index.frozen"), equalTo("true"));
468-
}, 2, TimeUnit.MINUTES);
469-
// assert that snapshot is still in progress and clean up
470-
assertThat(getSnapshotState(client(), "snapshot"), equalTo("SUCCESS"));
471-
assertOK(client().performRequest(new Request("DELETE", "/_snapshot/repo/snapshot")));
472-
}
473-
474411
public void testSetPriority() throws Exception {
475412
createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
476413
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.INDEX_PRIORITY_SETTING.getKey(), 100));

0 commit comments

Comments
 (0)