Skip to content

Commit 40a029f

Browse files
authored
Deprecate freeze index API (#72618)
1 parent c04fd6e commit 40a029f

File tree

13 files changed

+90
-11
lines changed

13 files changed

+90
-11
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
139139
public static final RequestOptions LEGACY_TEMPLATE_OPTIONS = RequestOptions.DEFAULT.toBuilder()
140140
.setWarningsHandler(warnings -> List.of(RestPutIndexTemplateAction.DEPRECATION_WARNING).equals(warnings) == false).build();
141141

142+
public static final String FROZEN_INDICES_DEPRECATION_WARNING = "Frozen indices are deprecated because they provide no benefit given " +
143+
"improvements in heap memory utilization. They will be removed in a future release.";
144+
142145
public void testIndicesExists() throws IOException {
143146
// Index present
144147
{
@@ -1530,13 +1533,16 @@ public void testFreezeAndUnfreeze() throws IOException {
15301533
createIndex("test", Settings.EMPTY);
15311534
RestHighLevelClient client = highLevelClient();
15321535

1536+
final RequestOptions freezeIndexOptions = RequestOptions.DEFAULT.toBuilder()
1537+
.setWarningsHandler(warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING).equals(warnings) == false).build();
1538+
15331539
ShardsAcknowledgedResponse freeze = execute(new FreezeIndexRequest("test"), client.indices()::freeze,
1534-
client.indices()::freezeAsync);
1540+
client.indices()::freezeAsync, freezeIndexOptions);
15351541
assertTrue(freeze.isShardsAcknowledged());
15361542
assertTrue(freeze.isAcknowledged());
15371543

15381544
ShardsAcknowledgedResponse unfreeze = execute(new UnfreezeIndexRequest("test"), client.indices()::unfreeze,
1539-
client.indices()::unfreezeAsync);
1545+
client.indices()::unfreezeAsync, freezeIndexOptions);
15401546
assertTrue(unfreeze.isShardsAcknowledged());
15411547
assertTrue(unfreeze.isAcknowledged());
15421548
}

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
import java.util.concurrent.CountDownLatch;
108108
import java.util.concurrent.TimeUnit;
109109

110+
import static org.elasticsearch.client.IndicesClientIT.FROZEN_INDICES_DEPRECATION_WARNING;
110111
import static org.elasticsearch.client.IndicesClientIT.LEGACY_TEMPLATE_OPTIONS;
111112
import static org.hamcrest.Matchers.containsInAnyOrder;
112113
import static org.hamcrest.Matchers.equalTo;
@@ -2885,8 +2886,11 @@ public void testFreezeIndex() throws Exception {
28852886
request.setIndicesOptions(IndicesOptions.strictExpandOpen()); // <1>
28862887
// end::freeze-index-request-indicesOptions
28872888

2889+
final RequestOptions freezeIndexOptions = RequestOptions.DEFAULT.toBuilder()
2890+
.setWarningsHandler(warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING).equals(warnings) == false).build();
2891+
28882892
// tag::freeze-index-execute
2889-
ShardsAcknowledgedResponse openIndexResponse = client.indices().freeze(request, RequestOptions.DEFAULT);
2893+
ShardsAcknowledgedResponse openIndexResponse = client.indices().freeze(request, freezeIndexOptions);
28902894
// end::freeze-index-execute
28912895

28922896
// tag::freeze-index-response
@@ -2964,7 +2968,9 @@ public void testUnfreezeIndex() throws Exception {
29642968
// end::unfreeze-index-request-indicesOptions
29652969

29662970
// tag::unfreeze-index-execute
2967-
ShardsAcknowledgedResponse openIndexResponse = client.indices().unfreeze(request, RequestOptions.DEFAULT);
2971+
final RequestOptions unfreezeIndexOptions = RequestOptions.DEFAULT.toBuilder()
2972+
.setWarningsHandler(warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING).equals(warnings) == false).build();
2973+
ShardsAcknowledgedResponse openIndexResponse = client.indices().unfreeze(request, unfreezeIndexOptions);
29682974
// end::unfreeze-index-execute
29692975

29702976
// tag::unfreeze-index-response

docs/reference/indices/apis/freeze.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ The following example freezes and unfreezes an index:
5757
POST /my-index-000001/_freeze
5858
POST /my-index-000001/_unfreeze
5959
--------------------------------------------------
60+
// TEST[skip:unable to ignore deprecation warning]
6061
// TEST[s/^/PUT my-index-000001\n/]
6162

docs/reference/indices/apis/unfreeze.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Unfreezes an index.
2222
[[unfreeze-index-api-desc]]
2323
==== {api-description-title}
2424

25-
When a frozen index is unfrozen, the index goes through the normal recovery
25+
When a frozen index is unfrozen, the index goes through the normal recovery
2626
process and becomes writeable again. See <<freeze-index-api>>.
2727

2828
IMPORTANT: Freezing an index will close the index and reopen it within the same
@@ -47,3 +47,4 @@ POST /my-index-000001/_freeze
4747
POST /my-index-000001/_unfreeze
4848
--------------------------------------------------
4949
// TEST[s/^/PUT my-index-000001\n/]
50+
// TEST[skip:unable to ignore deprecation warning]

docs/reference/indices/resolve.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ DELETE /_index_template/foo_data_stream
4949
----
5050
GET /_resolve/index/my-index-*
5151
----
52+
// TEST[skip:unable to ignore deprecation warning]
5253

5354
[[resolve-index-api-request]]
5455
==== {api-request-title}

x-pack/plugin/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ tasks.named("yamlRestCompatTest").configure {
103103

104104
//TODO: blacklist specific to REST API compatibility
105105
restTestBlacklist.addAll([
106+
'indices.freeze/10_basic/Basic',
107+
'indices.freeze/10_basic/Test index options',
108+
'indices.freeze/20_stats/Translog stats on frozen indices',
109+
'indices.freeze/30_usage/Usage stats on frozen indices',
106110
'license/30_enterprise_license/Installing enterprise license',
107111
'ml/data_frame_analytics_cat_apis/Test cat data frame analytics all jobs with header and column selection',
108112
'ml/data_frame_analytics_cat_apis/Test cat data frame analytics all jobs with header',

x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.elasticsearch.action.support.ActiveShardCount;
1010
import org.elasticsearch.action.support.IndicesOptions;
1111
import org.elasticsearch.client.node.NodeClient;
12+
import org.elasticsearch.common.RestApiVersion;
1213
import org.elasticsearch.common.Strings;
1314
import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
1415
import org.elasticsearch.rest.BaseRestHandler;
@@ -22,11 +23,20 @@
2223

2324
public final class RestFreezeIndexAction extends BaseRestHandler {
2425

26+
public static final String DEPRECATION_WARNING = "Frozen indices are deprecated because they provide no benefit given improvements " +
27+
"in heap memory utilization. They will be removed in a future release.";
28+
private static final RestApiVersion DEPRECATION_VERSION = RestApiVersion.V_8;
29+
2530
@Override
2631
public List<Route> routes() {
2732
return List.of(
28-
new Route(POST, "/{index}/_freeze"),
29-
new Route(POST, "/{index}/_unfreeze"));
33+
Route.builder(POST, "/{index}/_freeze")
34+
.deprecated(DEPRECATION_WARNING, DEPRECATION_VERSION)
35+
.build(),
36+
Route.builder(POST, "/{index}/_unfreeze")
37+
.deprecated(DEPRECATION_WARNING, DEPRECATION_VERSION)
38+
.build()
39+
);
3040
}
3141

3242
@Override

x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
public abstract class AbstractSearchableSnapshotsRestTestCase extends ESRestTestCase {
4747

48+
public static final String FROZEN_INDICES_WARNING = "Frozen indices are deprecated because they provide no benefit given "
49+
+ "improvements in heap memory utilization. They will be removed in a future release.";
50+
4851
private static final String WRITE_REPOSITORY_NAME = "repository";
4952
private static final String READ_REPOSITORY_NAME = "read-repository";
5053
private static final String SNAPSHOT_NAME = "searchable-snapshot";
@@ -173,6 +176,7 @@ public void testSearchResults() throws Exception {
173176
public void testSearchResultsWhenFrozen() throws Exception {
174177
runSearchableSnapshotsTest((restoredIndexName, numDocs) -> {
175178
final Request freezeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_freeze");
179+
freezeRequest.setOptions(expectWarnings(FROZEN_INDICES_WARNING));
176180
assertOK(client().performRequest(freezeRequest));
177181
ensureGreen(restoredIndexName);
178182
assertSearchResults(restoredIndexName, numDocs, Boolean.FALSE);
@@ -182,6 +186,7 @@ public void testSearchResultsWhenFrozen() throws Exception {
182186
assertThat(Boolean.valueOf(extractValue(frozenIndexSettings, "index.blocks.write")), equalTo(true));
183187

184188
final Request unfreezeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_unfreeze");
189+
unfreezeRequest.setOptions(expectWarnings(FROZEN_INDICES_WARNING));
185190
assertOK(client().performRequest(unfreezeRequest));
186191
ensureGreen(restoredIndexName);
187192
assertSearchResults(restoredIndexName, numDocs, Boolean.FALSE);
@@ -285,6 +290,7 @@ public void testSnapshotOfSearchableSnapshot() throws Exception {
285290
if (frozen) {
286291
logger.info("--> freezing index [{}]", restoredIndexName);
287292
final Request freezeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_freeze");
293+
freezeRequest.setOptions(expectWarnings(FROZEN_INDICES_WARNING));
288294
assertOK(client().performRequest(freezeRequest));
289295
}
290296

x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/DataLoader.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.List;
2929
import java.util.Map;
3030

31+
import static org.elasticsearch.test.rest.ESRestTestCase.expectWarnings;
32+
3133
public class DataLoader {
3234

3335
public static void main(String[] args) throws Exception {
@@ -393,7 +395,14 @@ public static void makeAlias(RestClient client, String aliasName, String... indi
393395

394396
protected static void freeze(RestClient client, String... indices) throws Exception {
395397
for (String index : indices) {
396-
client.performRequest(new Request("POST", "/" + index + "/_freeze"));
398+
Request freezeRequest = new Request("POST", "/" + index + "/_freeze");
399+
freezeRequest.setOptions(
400+
expectWarnings(
401+
"Frozen indices are deprecated because they provide no benefit given improvements in "
402+
+ "heap memory utilization. They will be removed in a future release."
403+
)
404+
);
405+
client.performRequest(freezeRequest);
397406
}
398407
}
399408

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/10_basic.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
"Basic":
3+
- skip:
4+
features: [ "warnings" ]
5+
36
- do:
47
index:
58
index: test
@@ -12,6 +15,8 @@
1215
body: { "foo": "Hello: 2" }
1316

1417
- do:
18+
warnings:
19+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
1520
indices.freeze:
1621
index: test
1722

@@ -29,6 +34,8 @@
2934

3035
# unfreeze
3136
- do:
37+
warnings:
38+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
3239
indices.unfreeze:
3340
index: test
3441

@@ -51,6 +58,8 @@
5158

5259

5360
- do:
61+
warnings:
62+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
5463
indices.freeze:
5564
index: test*
5665

@@ -81,7 +90,7 @@
8190
"Test index options":
8291

8392
- skip:
84-
features: ["allowed_warnings"]
93+
features: ["allowed_warnings", "warnings"]
8594

8695
- do:
8796
index:
@@ -102,6 +111,8 @@
102111
- "the default value for the ?wait_for_active_shards parameter will change from '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting' to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour"
103112

104113
- do:
114+
warnings:
115+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
105116
indices.freeze:
106117
index: test*,not_available
107118
ignore_unavailable: true

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/20_stats.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ setup:
1010
---
1111
"Translog stats on frozen indices":
1212
- skip:
13+
features: warnings
1314
version: " - 7.3.99"
1415
reason: "start ignoring translog retention policy with soft-deletes enabled in 7.4"
1516

@@ -39,6 +40,8 @@ setup:
3940

4041
# freeze index
4142
- do:
43+
warnings:
44+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
4245
indices.freeze:
4346
index: test
4447
- is_true: acknowledged
@@ -51,6 +54,8 @@ setup:
5154

5255
# unfreeze index
5356
- do:
57+
warnings:
58+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
5459
indices.unfreeze:
5560
index: test
5661
- is_true: acknowledged

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/30_usage.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ setup:
1010
---
1111
"Usage stats on frozen indices":
1212
- skip:
13+
features: [ "warnings" ]
1314
version: " - 7.3.99"
1415
reason: "frozen indices have usage stats starting in version 7.4"
1516

@@ -38,6 +39,8 @@ setup:
3839

3940
# freeze index
4041
- do:
42+
warnings:
43+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
4144
indices.freeze:
4245
index: test
4346
- is_true: acknowledged
@@ -50,6 +53,8 @@ setup:
5053

5154
# unfreeze index
5255
- do:
56+
warnings:
57+
- "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
5358
indices.unfreeze:
5459
index: test
5560
- is_true: acknowledged

x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,28 @@ public void testFrozenIndexAfterRestarted() throws Exception {
681681
ensureGreen(index);
682682
final int totalHits = (int) XContentMapValues.extractValue("hits.total.value",
683683
entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search"))));
684-
assertOK(client().performRequest(new Request("POST", index + "/_freeze")));
684+
Request freezeRequest = new Request("POST", index + "/_freeze");
685+
freezeRequest.setOptions(
686+
expectWarnings(
687+
"Frozen indices are deprecated because they provide no benefit given "
688+
+ "improvements in heap memory utilization. They will be removed in a future release."
689+
)
690+
);
691+
assertOK(client().performRequest(freezeRequest));
685692
ensureGreen(index);
686693
assertNoFileBasedRecovery(index, n -> true);
687694
final Request request = new Request("GET", "/" + index + "/_search");
688695
request.addParameter("ignore_throttled", "false");
689696
assertThat(XContentMapValues.extractValue("hits.total.value", entityAsMap(client().performRequest(request))),
690697
equalTo(totalHits));
691-
assertOK(client().performRequest(new Request("POST", index + "/_unfreeze")));
698+
final Request unfreezeRequest = new Request("POST", index + "/_unfreeze");
699+
unfreezeRequest.setOptions(
700+
expectWarnings(
701+
"Frozen indices are deprecated because they provide no benefit given "
702+
+ "improvements in heap memory utilization. They will be removed in a future release."
703+
)
704+
);
705+
assertOK(client().performRequest(unfreezeRequest));
692706
ensureGreen(index);
693707
assertNoFileBasedRecovery(index, n -> true);
694708
}

0 commit comments

Comments
 (0)