Skip to content

Commit a97b644

Browse files
committed
Deprecate lack of waiting on shards on index close
In 8.x the default for `?wait_for_active_shards` will change from `NONE` to `DEFAULT` on calls to `POST /index/_close`. This commit adds a deprecation warning in 7.x if this parameter is not specified to encourage users to adopt the new behaviour before upgrading. Closes elastic#66419
1 parent 9a9d480 commit a97b644

File tree

29 files changed

+69
-2
lines changed

29 files changed

+69
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@
399399
- do:
400400
indices.close:
401401
index: test_index
402+
wait_for_active_shards: DEFAULT
402403

403404
- do:
404405
cat.aliases:
@@ -432,6 +433,7 @@
432433
- do:
433434
indices.close:
434435
index: test_index
436+
wait_for_active_shards: DEFAULT
435437

436438
- do:
437439
node_selector:

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
- do:
6767
indices.close:
6868
index: index-2
69+
wait_for_active_shards: DEFAULT
6970
- is_true: acknowledged
7071

7172
- do:
@@ -107,6 +108,7 @@
107108
- do:
108109
indices.close:
109110
index: index-2
111+
wait_for_active_shards: DEFAULT
110112
- is_true: acknowledged
111113

112114
- do:
@@ -249,6 +251,7 @@
249251
- do:
250252
indices.close:
251253
index: bar
254+
wait_for_active_shards: DEFAULT
252255

253256
- do:
254257
cat.indices:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
- do:
9494
indices.close:
9595
index: index2
96+
wait_for_active_shards: DEFAULT
9697
- is_true: acknowledged
9798

9899
- do:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
- do:
9696
indices.close:
9797
index: index1
98+
wait_for_active_shards: DEFAULT
9899

99100
- do:
100101
catch: bad_request

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.allocation_explain/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
- do:
6969
indices.close:
7070
index: test_closed
71+
wait_for_active_shards: DEFAULT
7172

7273
- match: { acknowledged: true }
7374

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
- do:
184184
indices.close:
185185
index: index-2
186+
wait_for_active_shards: DEFAULT
186187
- is_true: acknowledged
187188

188189
# closing the index-2 turns the cluster health back to green
@@ -258,6 +259,7 @@
258259
- do:
259260
indices.close:
260261
index: index-2
262+
wait_for_active_shards: DEFAULT
261263
- is_true: acknowledged
262264

263265
- do:

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/30_indices_options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ setup:
2323
- do:
2424
indices.close:
2525
index: index-2
26+
wait_for_active_shards: DEFAULT
2627

2728
- do:
2829
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/30_expand_wildcards.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ setup:
2525
- do:
2626
indices.close:
2727
index: test_close_index
28+
wait_for_active_shards: DEFAULT
2829

2930
---
3031
"Test expand_wildcards parameter on closed, open indices and both":

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ setup:
3838
- do:
3939
indices.close:
4040
index: test_index_3
41+
wait_for_active_shards: DEFAULT
4142

4243
- do:
4344
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get/11_basic_with_types.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ setup:
3737
- do:
3838
indices.close:
3939
index: test_index_3
40+
wait_for_active_shards: DEFAULT
4041

4142
- do:
4243
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_alias/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ setup:
307307
- do:
308308
indices.close:
309309
index: test_index_2
310+
wait_for_active_shards: DEFAULT
310311

311312
- do:
312313
indices.get_alias:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/50_wildcard_expansion.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ setup:
5252
- do:
5353
indices.close:
5454
index: test-xyy
55+
wait_for_active_shards: DEFAULT
5556

5657
- do:
5758
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.open/10_basic.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- do:
1515
indices.close:
1616
index: test_index
17+
wait_for_active_shards: DEFAULT
1718
- is_true: acknowledged
1819

1920
- do:
@@ -52,6 +53,7 @@
5253
- do:
5354
indices.close:
5455
index: test_index
56+
wait_for_active_shards: DEFAULT
5557
- is_true: acknowledged
5658

5759
- do:
@@ -83,6 +85,27 @@
8385
- match: { acknowledged: true }
8486
- match: { shards_acknowledged: true }
8587
---
88+
"Close index without specifying wait_for_active_shards":
89+
- skip:
90+
version: " - 7.1.99"
91+
reason: "closed indices are replicated starting version 7.2.0"
92+
features: ["warnings", "node_selector"]
93+
94+
- do:
95+
indices.create:
96+
index: test_index
97+
body:
98+
settings:
99+
number_of_replicas: 0
100+
101+
- do:
102+
indices.close:
103+
index: test_index
104+
warnings:
105+
- "When closing an index in 8.0 the default behaviour will change from ?wait_for_active_shards=NONE to ?wait_for_active_shards=DEFAULT. To opt-in to the new default, set ?wait_for_active_shards=DEFAULT when closing indices."
106+
node_selector:
107+
version: "7.12.0 - "
108+
---
86109
"Close index response with result per index":
87110
- skip:
88111
version: " - 7.2.99"
@@ -112,6 +135,7 @@
112135
- do:
113136
indices.close:
114137
index: "index_*"
138+
wait_for_active_shards: DEFAULT
115139

116140
- match: { acknowledged: true }
117141
- match: { shards_acknowledged: true }

rest-api-spec/src/main/resources/rest-api-spec/test/indices.open/20_multiple_indices.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ setup:
2626
- do:
2727
indices.close:
2828
index: _all
29+
wait_for_active_shards: DEFAULT
2930
- is_true: acknowledged
3031

3132
- do:
@@ -53,6 +54,7 @@ setup:
5354
- do:
5455
indices.close:
5556
index: test_*
57+
wait_for_active_shards: DEFAULT
5658
- is_true: acknowledged
5759

5860
- do:
@@ -80,6 +82,7 @@ setup:
8082
- do:
8183
indices.close:
8284
index: '*'
85+
wait_for_active_shards: DEFAULT
8386
- is_true: acknowledged
8487

8588
- do:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_settings/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ setup:
8989
- do:
9090
indices.close:
9191
index: test-index
92+
wait_for_active_shards: DEFAULT
9293

9394
- do:
9495
indices.put_settings:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.recovery/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
- do:
5757
indices.close:
5858
index: test_2
59+
wait_for_active_shards: DEFAULT
5960
- is_true: acknowledged
6061

6162
- do:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.resolve_index/10_basic_resolve_index.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ setup:
2424
- do:
2525
indices.close:
2626
index: test_index2
27+
wait_for_active_shards: DEFAULT
2728

2829
- do:
2930
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.segments/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
- do:
6161
indices.close:
6262
index: index1
63+
wait_for_active_shards: DEFAULT
6364

6465
- do:
6566
catch: bad_request

rest-api-spec/src/main/resources/rest-api-spec/test/search/80_indices_options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- do:
3535
indices.close:
3636
index: index_closed
37+
wait_for_active_shards: DEFAULT
3738

3839
- do:
3940
catch: /index_closed_exception/

rest-api-spec/src/main/resources/rest-api-spec/test/snapshot.restore/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ setup:
4040
- do:
4141
indices.close:
4242
index : test_index
43+
wait_for_active_shards: DEFAULT
4344

4445
- do:
4546
snapshot.restore:

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.action.support.IndicesOptions;
2525
import org.elasticsearch.client.node.NodeClient;
2626
import org.elasticsearch.common.Strings;
27+
import org.elasticsearch.common.logging.DeprecationLogger;
2728
import org.elasticsearch.rest.BaseRestHandler;
2829
import org.elasticsearch.rest.RestRequest;
2930
import org.elasticsearch.rest.action.RestToXContentListener;
@@ -37,6 +38,8 @@
3738

3839
public class RestCloseIndexAction extends BaseRestHandler {
3940

41+
private static final DeprecationLogger logger = DeprecationLogger.getLogger(RestCloseIndexAction.class);
42+
4043
@Override
4144
public List<Route> routes() {
4245
return unmodifiableList(asList(
@@ -55,8 +58,12 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
5558
closeIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", closeIndexRequest.masterNodeTimeout()));
5659
closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout()));
5760
closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
58-
String waitForActiveShards = request.param("wait_for_active_shards");
59-
if (waitForActiveShards != null) {
61+
final String waitForActiveShards = request.param("wait_for_active_shards");
62+
if (waitForActiveShards == null) {
63+
logger.deprecate("close-index-wait-for-active-shards", "When closing an index in 8.0 the default behaviour will change from " +
64+
"?wait_for_active_shards=NONE to ?wait_for_active_shards=DEFAULT. To opt-in to the new default, set " +
65+
"?wait_for_active_shards=DEFAULT when closing indices.");
66+
} else {
6067
closeIndexRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
6168
}
6269
return channel -> client.admin().indices().close(closeIndexRequest, new RestToXContentListener<>(channel));

x-pack/plugin/src/test/resources/rest-api-spec/test/data_stream/20_unsupported_apis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
- do:
4646
indices.close:
4747
index: logs-*
48+
wait_for_active_shards: DEFAULT
4849
- is_true: acknowledged
4950
- length: { indices: 0 }
5051

@@ -165,6 +166,7 @@
165166
catch: bad_request
166167
indices.close:
167168
index: ".ds-simple-data-stream1-*000001"
169+
wait_for_active_shards: DEFAULT
168170

169171
- do:
170172
indices.delete_data_stream:

x-pack/plugin/src/test/resources/rest-api-spec/test/data_stream/40_supported_apis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ teardown:
230230
- do:
231231
indices.close:
232232
index: ".ds-simple-data-stream1-*000001,.ds-simple-data-stream1-*000002"
233+
wait_for_active_shards: DEFAULT
233234
- is_true: acknowledged
234235

235236
- do:

x-pack/plugin/src/test/resources/rest-api-spec/test/data_stream/80_resolve_index_data_streams.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ setup:
5454
- do:
5555
indices.close:
5656
index: test_index2
57+
wait_for_active_shards: DEFAULT
5758

5859
- do:
5960
indices.create:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
- do:
105105
indices.close:
106106
index: test-close
107+
wait_for_active_shards: DEFAULT
107108

108109
- do:
109110
indices.freeze:

x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,7 @@
12231223
- do:
12241224
indices.close:
12251225
index: ".ml-anomalies-shared"
1226+
wait_for_active_shards: DEFAULT
12261227

12271228
- do:
12281229
catch: /Cannot create job \[closed-results-job\] as it requires closed index \[\.ml-anomalies-shared\]/
@@ -1250,6 +1251,7 @@
12501251
- do:
12511252
indices.close:
12521253
index: ".ml-state-000001"
1254+
wait_for_active_shards: DEFAULT
12531255

12541256
- do:
12551257
catch: /Cannot create job \[closed-results-job\] as it requires closed index \[\.ml-state-000001\]/

x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
- do:
207207
indices.close:
208208
index: .monitoring-beats-*
209+
wait_for_active_shards: DEFAULT
209210

210211
- do:
211212
catch: /export_exception/

x-pack/plugin/src/test/resources/rest-api-spec/test/security/authz/14_cat_indices.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ setup:
5555
- do:
5656
indices.close:
5757
index: index3
58+
wait_for_active_shards: DEFAULT
5859

5960
---
6061
teardown:
@@ -150,6 +151,7 @@ teardown:
150151
- do:
151152
indices.close:
152153
index: index_to_monitor
154+
wait_for_active_shards: DEFAULT
153155

154156
- do:
155157
headers: { Authorization: "Basic Y2F0X3VzZXI6Y2F0X3Bhc3N3b3Jk" } # cat_user

x-pack/plugin/src/test/resources/rest-api-spec/test/snapshot/10_basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ setup:
5353
- do:
5454
indices.close:
5555
index : test_index
56+
wait_for_active_shards: DEFAULT
5657

5758
- do:
5859
snapshot.restore:

0 commit comments

Comments
 (0)