Skip to content

Commit 11381c3

Browse files
committed
Revert "Warn of change of default of wait_for_active_shards (#67246)"
This reverts commit 8660e8d.
1 parent 29c5abc commit 11381c3

File tree

58 files changed

+42
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+42
-308
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
3939
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
4040
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
41-
import org.elasticsearch.action.support.ActiveShardCount;
4241
import org.elasticsearch.client.indices.AnalyzeRequest;
4342
import org.elasticsearch.client.indices.CloseIndexRequest;
4443
import org.elasticsearch.client.indices.CreateDataStreamRequest;
@@ -141,13 +140,6 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) {
141140
parameters.withTimeout(closeIndexRequest.timeout());
142141
parameters.withMasterTimeout(closeIndexRequest.masterNodeTimeout());
143142
parameters.withIndicesOptions(closeIndexRequest.indicesOptions());
144-
145-
final ActiveShardCount activeShardCount = closeIndexRequest.waitForActiveShards();
146-
if (activeShardCount == ActiveShardCount.DEFAULT) {
147-
request.addParameter("wait_for_active_shards", "index-setting");
148-
} else {
149-
parameters.withWaitForActiveShards(activeShardCount);
150-
}
151143
request.addParameters(parameters.asMap());
152144
return request;
153145
}

client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CloseIndexRequest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.client.indices;
2121

22+
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
2223
import org.elasticsearch.action.support.ActiveShardCount;
2324
import org.elasticsearch.action.support.IndicesOptions;
2425
import org.elasticsearch.client.TimedRequest;
@@ -34,7 +35,7 @@ public class CloseIndexRequest extends TimedRequest implements Validatable {
3435

3536
private String[] indices;
3637
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
37-
private ActiveShardCount waitForActiveShards = null;
38+
private ActiveShardCount waitForActiveShards = ActiveShardCount.DEFAULT;
3839

3940
/**
4041
* Creates a new close index request
@@ -81,14 +82,16 @@ public ActiveShardCount waitForActiveShards() {
8182
}
8283

8384
/**
84-
* Sets the number of shard copies that should be active before a close-index request returns. Defaults to {@code null}, which means not
85-
* to wait. However the default behaviour is deprecated and will change in version 8. You can opt-in to the new default behaviour now by
86-
* setting this to {@link ActiveShardCount#DEFAULT}, which will wait according to the setting {@code index.write.wait_for_active_shards}
87-
* which by default will wait for one shard, the primary. Set this value to {@link ActiveShardCount#ALL} to wait for all shards (primary
88-
* and all replicas) to be active before returning. Otherwise, use {@link ActiveShardCount#from(int)} to set this value to any
89-
* non-negative integer up to the number of copies per shard (number of replicas + 1), to wait for the desired amount of shard copies
90-
* to become active before returning. To explicitly preserve today's default behaviour and suppress the deprecation warning, set this
91-
* property to {@code ActiveShardCount.from(0)}.
85+
* Sets the number of shard copies that should be active for indices opening to return.
86+
* Defaults to {@link ActiveShardCount#DEFAULT}, which will wait for one shard copy
87+
* (the primary) to become active. Set this value to {@link ActiveShardCount#ALL} to
88+
* wait for all shards (primary and all replicas) to be active before returning.
89+
* Otherwise, use {@link ActiveShardCount#from(int)} to set this value to any
90+
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
91+
* to wait for the desired amount of shard copies to become active before returning.
92+
* Indices opening will only wait up until the timeout value for the number of shard copies
93+
* to be active before returning. Check {@link OpenIndexResponse#isShardsAcknowledged()} to
94+
* determine if the requisite shard copies were all started before returning or timing out.
9295
*
9396
* @param waitForActiveShards number of active shard copies to wait on
9497
*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ public void testIndexFollowing() throws Exception {
188188

189189
// Need to close index prior to unfollowing it:
190190
CloseIndexRequest closeIndexRequest = new CloseIndexRequest("follower");
191-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(0));
192191
org.elasticsearch.action.support.master.AcknowledgedResponse closeIndexReponse =
193192
highLevelClient().indices().close(closeIndexRequest, RequestOptions.DEFAULT);
194193
assertThat(closeIndexReponse.isAcknowledged(), is(true));

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
5151
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse;
5252
import org.elasticsearch.action.index.IndexRequest;
53-
import org.elasticsearch.action.support.ActiveShardCount;
5453
import org.elasticsearch.action.support.IndicesOptions;
5554
import org.elasticsearch.action.support.WriteRequest;
5655
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
@@ -905,7 +904,6 @@ public void testCloseExistingIndex() throws IOException {
905904
}
906905

907906
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(indices);
908-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(0));
909907
CloseIndexResponse closeIndexResponse = execute(closeIndexRequest,
910908
highLevelClient().indices()::close, highLevelClient().indices()::closeAsync);
911909
assertTrue(closeIndexResponse.isAcknowledged());
@@ -928,7 +926,6 @@ public void testCloseNonExistentIndex() throws IOException {
928926
assertFalse(indexExists(nonExistentIndex));
929927

930928
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(nonExistentIndex);
931-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(0));
932929
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
933930
() -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync));
934931
assertEquals(RestStatus.NOT_FOUND, exception.status());
@@ -937,7 +934,6 @@ public void testCloseNonExistentIndex() throws IOException {
937934
public void testCloseEmptyOrNullIndex() {
938935
String[] indices = randomBoolean() ? Strings.EMPTY_ARRAY : null;
939936
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(indices);
940-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(0));
941937
org.elasticsearch.client.ValidationException exception = expectThrows(org.elasticsearch.client.ValidationException.class,
942938
() -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync));
943939
assertThat(exception.validationErrors().get(0), equalTo("index is missing"));

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
4242
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
4343
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
44-
import org.elasticsearch.action.support.ActiveShardCount;
4544
import org.elasticsearch.action.support.master.AcknowledgedRequest;
4645
import org.elasticsearch.client.indices.AnalyzeRequest;
4746
import org.elasticsearch.client.indices.CloseIndexRequest;
@@ -642,22 +641,6 @@ public void testCloseIndex() {
642641
RequestConvertersTests.setRandomMasterTimeout(closeIndexRequest, expectedParams);
643642
RequestConvertersTests.setRandomIndicesOptions(closeIndexRequest::indicesOptions, closeIndexRequest::indicesOptions,
644643
expectedParams);
645-
switch (between(0, 3)) {
646-
case 0:
647-
break;
648-
case 1:
649-
closeIndexRequest.waitForActiveShards(ActiveShardCount.DEFAULT);
650-
expectedParams.put("wait_for_active_shards", "index-setting");
651-
break;
652-
case 2:
653-
closeIndexRequest.waitForActiveShards(ActiveShardCount.ALL);
654-
expectedParams.put("wait_for_active_shards", "all");
655-
break;
656-
case 3:
657-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(1));
658-
expectedParams.put("wait_for_active_shards", "1");
659-
break;
660-
}
661644

662645
Request request = IndicesRequestConverters.closeIndex(closeIndexRequest);
663646
StringJoiner endpoint = new StringJoiner("/", "/", "").add(String.join(",", indices)).add("_close");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testRankEvalRequest() throws IOException {
108108
}
109109

110110
// now try this when test2 is closed
111-
closeIndex("index2");
111+
client().performRequest(new Request("POST", "index2/_close"));
112112
rankEvalRequest.indicesOptions(IndicesOptions.fromParameters(null, "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
113113
response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
114114
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ public void testUnfollow() throws Exception {
321321
assertThat(unfollowResponse.isAcknowledged(), is(true));
322322

323323
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(followIndex);
324-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(0));
325324
assertThat(client.indices().close(closeIndexRequest, RequestOptions.DEFAULT).isAcknowledged(), is(true));
326325
}
327326

@@ -354,7 +353,6 @@ public void testUnfollow() throws Exception {
354353
assertThat(unfollowResponse.isAcknowledged(), is(true));
355354

356355
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(followIndex);
357-
closeIndexRequest.waitForActiveShards(ActiveShardCount.from(0));
358356
assertThat(client.indices().close(closeIndexRequest, RequestOptions.DEFAULT).isAcknowledged(), is(true));
359357
}
360358

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,8 +1469,6 @@ public void testCloseIndex() throws Exception {
14691469
CloseIndexRequest request = new CloseIndexRequest("index"); // <1>
14701470
// end::close-index-request
14711471

1472-
request.waitForActiveShards(ActiveShardCount.from(0));
1473-
14741472
// tag::close-index-request-timeout
14751473
request.setTimeout(TimeValue.timeValueMinutes(2)); // <1>
14761474
// end::close-index-request-timeout

distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/WaitForRefreshAndCloseIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ private void closeWhileListenerEngaged(ActionFuture<String> future) throws Excep
9797
});
9898

9999
// Close the index. That should flush the listener.
100-
final Request closeRequest = new Request("POST", "/test/_close");
101-
closeRequest.addParameter("wait_for_active_shards", "0");
102-
client().performRequest(closeRequest);
100+
client().performRequest(new Request("POST", "/test/_close"));
103101

104102
/*
105103
* The request may fail, but we really, really, really want to make

docs/reference/ccr/apis/follow/post-unfollow.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PUT /follower_index/_ccr/follow?wait_for_active_shards=1
2323
2424
POST /follower_index/_ccr/pause_follow
2525
26-
POST /follower_index/_close?wait_for_active_shards=0
26+
POST /follower_index/_close
2727
--------------------------------------------------
2828
// TESTSETUP
2929
// TEST[setup:remote_cluster_and_leader_index]

docs/reference/ccr/getting-started.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ replication
243243
--------------------------------------------------
244244
POST /server-metrics-follower/_ccr/pause_follow
245245
246-
POST /server-metrics-follower/_close?wait_for_active_shards=0
246+
POST /server-metrics-follower/_close
247247
248248
POST /server-metrics-follower/_ccr/unfollow
249249
--------------------------------------------------

docs/reference/ccr/managing.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ process. Then, close the follower index and recreate it. For example:
127127
----------------------------------------------------------------------
128128
POST /follower_index/_ccr/pause_follow
129129
130-
POST /follower_index/_close?wait_for_active_shards=0
130+
POST /follower_index/_close
131131
132132
PUT /follower_index/_ccr/follow?wait_for_active_shards=1
133133
{

docs/reference/index-modules/similarity.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ request and <<indices-open-close,open>> it again afterwards:
540540

541541
[source,console]
542542
--------------------------------------------------
543-
POST /index/_close?wait_for_active_shards=0
543+
POST /index/_close
544544
545545
PUT /index/_settings
546546
{

docs/reference/indices/close.asciidoc

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Closes an index.
1111
POST /my-index-000001/_close
1212
--------------------------------------------------
1313
// TEST[setup:my_index]
14-
// TEST[warning: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]
1514

1615

1716
[[close-index-api-request]]
@@ -53,18 +52,7 @@ Defaults to `open`.
5352

5453
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
5554

56-
`wait_for_active_shards`::
57-
+
58-
--
59-
(Optional, string) The number of shard copies that must be active before
60-
proceeding with the operation. Set to `all`, `index-setting`, or any positive
61-
integer up to the total number of shards in the index (`number_of_replicas+1`).
62-
The value `index-setting` means to wait according to the index setting
63-
`index.write.wait_for_active_shards`. Default: `0`, meaning do not wait for any
64-
shards to be ready.
65-
66-
See <<index-wait-for-active-shards>>.
67-
--
55+
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
6856

6957
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
7058

@@ -78,8 +66,7 @@ The following example shows how to close an index:
7866
--------------------------------------------------
7967
POST /my-index-000001/_close
8068
--------------------------------------------------
81-
// TEST[setup:my_index]
82-
// TEST[warning: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]
69+
// TEST[s/^/PUT my-index-000001\n/]
8370

8471
The API returns following response:
8572

docs/reference/indices/open-close.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ opens any closed backing indices.
1212
POST /my-index-000001/_open
1313
--------------------------------------------------
1414
// TEST[setup:my_index]
15-
// TEST[s/^/POST \/my-index-000001\/_close?wait_for_active_shards=0\n/]
15+
// TEST[s/^/POST \/my-index-000001\/_close\n/]
1616

1717

1818
[[open-index-api-request]]
@@ -122,7 +122,7 @@ The following request re-opens a closed index named `my-index-000001`.
122122
--------------------------------------------------
123123
POST /my-index-000001/_open
124124
--------------------------------------------------
125-
// TEST[s/^/PUT my-index-000001\nPOST my-index-000001\/_close?wait_for_active_shards=0\n/]
125+
// TEST[s/^/PUT my-index-000001\nPOST my-index-000001\/_close\n/]
126126

127127
The API returns the following response:
128128

docs/reference/indices/resolve.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ supported.
1313
----
1414
PUT /foo_closed
1515
16-
POST /foo_closed/_close?wait_for_active_shards=0
16+
POST /foo_closed/_close
1717
1818
PUT /remotecluster-bar-01
1919

docs/reference/indices/update-settings.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ the following commands add the `content` analyzer to the `my-index-000001` index
167167

168168
[source,console]
169169
--------------------------------------------------
170-
POST /my-index-000001/_close?wait_for_active_shards=0
170+
POST /my-index-000001/_close
171171
172172
PUT /my-index-000001/_settings
173173
{

docs/reference/snapshot-restore/apis/restore-snapshot-api.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ PUT _snapshot/my_repository/snapshot_2?wait_for_completion=true
3838
}
3939
}
4040
41-
POST /index_1/_close?wait_for_active_shards=0
41+
POST /index_1/_close
4242
43-
POST /index_2/_close?wait_for_active_shards=0
43+
POST /index_2/_close
4444
45-
POST /index_3/_close?wait_for_active_shards=0
45+
POST /index_3/_close
4646
47-
POST /index_4/_close?wait_for_active_shards=0
47+
POST /index_4/_close
4848
4949
----
5050
// TESTSETUP

plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/40_restore.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#
55
---
66
"Create a snapshot and then restore it":
7-
- skip:
8-
features: ["allowed_warnings"]
97

108
# Create repository
119
- do:
@@ -49,8 +47,6 @@
4947
- do:
5048
indices.close:
5149
index : test_index
52-
allowed_warnings:
53-
- "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"
5450

5551
# Restore index
5652
- do:

plugins/repository-hdfs/src/test/resources/rest-api-spec/test/secure_hdfs_repository/40_restore.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#
55
---
66
"Create a snapshot and then restore it":
7-
- skip:
8-
features: ["allowed_warnings"]
97

108
# Create repository
119
- do:
@@ -51,8 +49,6 @@
5149
- do:
5250
indices.close:
5351
index : test_index
54-
allowed_warnings:
55-
- "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"
5652

5753
# Restore index
5854
- do:

rest-api-spec/src/main/resources/rest-api-spec/api/indices.close.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757
"wait_for_active_shards":{
5858
"type":"string",
59-
"description":"Sets the number of active shards to wait for before the operation returns. Set to `index-setting` to wait according to the index setting `index.write.wait_for_active_shards`, or `all` to wait for all shards, or an integer. Defaults to `0`."
59+
"description":"Sets the number of active shards to wait for before the operation returns."
6060
}
6161
}
6262
}

rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@
388388
- skip:
389389
version: " - 7.3.99"
390390
reason: "is_write_index is shown in cat.aliases starting version 7.4.0"
391-
features: ["allowed_warnings"]
392391

393392
- do:
394393
indices.create:
@@ -400,8 +399,6 @@
400399
- do:
401400
indices.close:
402401
index: test_index
403-
allowed_warnings:
404-
- "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"
405402

406403
- do:
407404
cat.aliases:
@@ -422,7 +419,7 @@
422419
"Alias against closed index (pre 7.4.0)":
423420
- skip:
424421
version: "7.4.0 - "
425-
features: ["node_selector", "allowed_warnings"]
422+
features: node_selector
426423
reason: "is_write_index is shown in cat.aliases starting version 7.4.0"
427424

428425
- do:
@@ -435,8 +432,6 @@
435432
- do:
436433
indices.close:
437434
index: test_index
438-
allowed_warnings:
439-
- "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"
440435

441436
- do:
442437
node_selector:

0 commit comments

Comments
 (0)