Skip to content

Commit d68c44b

Browse files
authored
Default copy settings to true and deprecate on the REST layer (elastic#30598)
This commit defaults the copy_settings REST parameter to the shrink and split APIs to true, and deprecates the parameter.
1 parent 33cba44 commit d68c44b

File tree

18 files changed

+129
-129
lines changed

18 files changed

+129
-129
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,12 @@ public void testShrink() throws IOException {
642642

643643
ResizeRequest resizeRequest = new ResizeRequest("target", "source");
644644
resizeRequest.setResizeType(ResizeType.SHRINK);
645-
Settings targetSettings = Settings.builder().put("index.number_of_shards", 2).put("index.number_of_replicas", 0).build();
645+
Settings targetSettings =
646+
Settings.builder()
647+
.put("index.number_of_shards", 2)
648+
.put("index.number_of_replicas", 0)
649+
.putNull("index.routing.allocation.require._name")
650+
.build();
646651
resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias")));
647652
ResizeResponse resizeResponse = highLevelClient().indices().shrink(resizeRequest);
648653
assertTrue(resizeResponse.isAcknowledged());

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,8 @@ public void testShrinkIndex() throws Exception {
13051305
// end::shrink-index-request-waitForActiveShards
13061306
// tag::shrink-index-request-settings
13071307
request.getTargetIndexRequest().settings(Settings.builder()
1308-
.put("index.number_of_shards", 2)); // <1>
1308+
.put("index.number_of_shards", 2) // <1>
1309+
.putNull("index.routing.allocation.require._name")); // <2>
13091310
// end::shrink-index-request-settings
13101311
// tag::shrink-index-request-aliases
13111312
request.getTargetIndexRequest().alias(new Alias("target_alias")); // <1>

docs/java-rest/high-level/indices/shrink_index.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ returns a response, as an `ActiveShardCount`
4545
--------------------------------------------------
4646
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-settings]
4747
--------------------------------------------------
48-
<1> The settings to apply to the target index, which include the number of
49-
shards to create for it
48+
<1> The number of shards on the target of the shrink index request
49+
<2> Remove the allocation requirement copied from the source index
5050

5151
["source","java",subs="attributes,callouts,macros"]
5252
--------------------------------------------------

docs/reference/indices/shrink-index.asciidoc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ the following request:
6262

6363
[source,js]
6464
--------------------------------------------------
65-
POST my_source_index/_shrink/my_target_index?copy_settings=true
65+
POST my_source_index/_shrink/my_target_index
6666
{
6767
"settings": {
6868
"index.routing.allocation.require._name": null, <1>
@@ -106,7 +106,7 @@ and accepts `settings` and `aliases` parameters for the target index:
106106

107107
[source,js]
108108
--------------------------------------------------
109-
POST my_source_index/_shrink/my_target_index?copy_settings=true
109+
POST my_source_index/_shrink/my_target_index
110110
{
111111
"settings": {
112112
"index.number_of_replicas": 1,
@@ -130,16 +130,6 @@ POST my_source_index/_shrink/my_target_index?copy_settings=true
130130

131131
NOTE: Mappings may not be specified in the `_shrink` request.
132132

133-
NOTE: By default, with the exception of `index.analysis`, `index.similarity`,
134-
and `index.sort` settings, index settings on the source index are not copied
135-
during a shrink operation. With the exception of non-copyable settings, settings
136-
from the source index can be copied to the target index by adding the URL
137-
parameter `copy_settings=true` to the request. Note that `copy_settings` can not
138-
be set to `false`. The parameter `copy_settings` will be removed in 8.0.0
139-
140-
deprecated[6.4.0, not copying settings is deprecated, copying settings will be
141-
the default behavior in 7.x]
142-
143133
[float]
144134
=== Monitoring the shrink process
145135

docs/reference/indices/split-index.asciidoc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ the following request:
123123

124124
[source,js]
125125
--------------------------------------------------
126-
POST my_source_index/_split/my_target_index?copy_settings=true
126+
POST my_source_index/_split/my_target_index
127127
{
128128
"settings": {
129129
"index.number_of_shards": 2
@@ -158,7 +158,7 @@ and accepts `settings` and `aliases` parameters for the target index:
158158

159159
[source,js]
160160
--------------------------------------------------
161-
POST my_source_index/_split/my_target_index?copy_settings=true
161+
POST my_source_index/_split/my_target_index
162162
{
163163
"settings": {
164164
"index.number_of_shards": 5 <1>
@@ -177,16 +177,6 @@ POST my_source_index/_split/my_target_index?copy_settings=true
177177

178178
NOTE: Mappings may not be specified in the `_split` request.
179179

180-
NOTE: By default, with the exception of `index.analysis`, `index.similarity`,
181-
and `index.sort` settings, index settings on the source index are not copied
182-
during a split operation. With the exception of non-copyable settings, settings
183-
from the source index can be copied to the target index by adding the URL
184-
parameter `copy_settings=true` to the request. Note that `copy_settings` can not
185-
be set to `false`. The parameter `copy_settings` will be removed in 8.0.0
186-
187-
deprecated[6.4.0, not copying settings is deprecated, copying settings will be
188-
the default behavior in 7.x]
189-
190180
[float]
191181
=== Monitoring the split process
192182

docs/reference/migration/migrate_7_0/api.asciidoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ deprecated in 6.3.0 and now removed in 7.0.0.
6565
In the past, `fields` could be provided either as a parameter, or as part of the request
6666
body. Specifying `fields` in the request body as opposed to a parameter was deprecated
6767
in 6.4.0, and is now unsupported in 7.0.0.
68+
69+
==== `copy_settings` is deprecated on shrink and split APIs
70+
71+
Versions of Elasticsearch prior to 6.4.0 did not copy index settings on shrink
72+
and split operations. Starting with Elasticsearch 7.0.0, the default behavior
73+
will be for such settings to be copied on such operations. To enable users in
74+
6.4.0 to transition in 6.4.0 to the default behavior in 7.0.0, the
75+
`copy_settings` parameter was added on the REST layer. As this behavior will be
76+
the only behavior in 8.0.0, this parameter is deprecated in 7.0.0 for removal in
77+
8.0.0.

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
"Shrink index via API":
33
- skip:
4-
version: " - 6.3.99"
5-
reason: expects warnings that pre-6.4.0 will not send
4+
version: " - 6.9.99"
5+
reason: expects warnings that pre-7.0.0 will not send
66
features: "warnings"
77
# creates an index with one document solely allocated on the master node
88
# and shrinks it into a new index with a single shard
@@ -67,8 +67,6 @@
6767
body:
6868
settings:
6969
index.number_of_replicas: 0
70-
warnings:
71-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
7270

7371
- do:
7472
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/20_source_mapping.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
"Shrink index ignores target template mapping":
33
- skip:
4-
version: " - 6.3.99"
5-
reason: expects warnings that pre-6.4.0 will not send
4+
version: " - 6.9.99"
5+
reason: expects warnings that pre-7.0.0 will not send
66
features: "warnings"
77

88
- do:
@@ -71,8 +71,6 @@
7171
body:
7272
settings:
7373
index.number_of_replicas: 0
74-
warnings:
75-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
7674

7775
- do:
7876
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/30_copy_settings.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
"Copy settings during shrink index":
33
- skip:
4-
version: " - 6.3.99"
5-
reason: expects warnings that pre-6.4.0 will not send
4+
version: " - 6.9.99"
5+
reason: expects warnings that pre-7.0.0 will not send
66
features: "warnings"
77

88
- do:
@@ -48,6 +48,8 @@
4848
settings:
4949
index.number_of_replicas: 0
5050
index.merge.scheduler.max_thread_count: 2
51+
warnings:
52+
- "parameter [copy_settings] is deprecated and will be removed in 8.0.0"
5153

5254
- do:
5355
cluster.health:
@@ -63,33 +65,31 @@
6365
- match: { copy-settings-target.settings.index.blocks.write: "true" }
6466
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
6567

66-
# now we do a actual shrink and do not copy settings (by default)
68+
# now we do a actual shrink and copy settings (by default)
6769
- do:
6870
indices.shrink:
6971
index: "source"
70-
target: "no-copy-settings-target"
72+
target: "default-copy-settings-target"
7173
wait_for_active_shards: 1
7274
master_timeout: 10s
7375
body:
7476
settings:
7577
index.number_of_replicas: 0
7678
index.merge.scheduler.max_thread_count: 2
77-
warnings:
78-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
7979

8080
- do:
8181
cluster.health:
8282
wait_for_status: green
8383

8484
- do:
8585
indices.get_settings:
86-
index: "no-copy-settings-target"
86+
index: "default-copy-settings-target"
8787

88-
# only the request setting should be copied
89-
- is_false: no-copy-settings-target.settings.index.merge.scheduler.max_merge_count
90-
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
91-
- is_false: no-copy-settings-target.settings.index.blocks.write
92-
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id
88+
# settings should be copied
89+
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" }
90+
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
91+
- match: { default-copy-settings-target.settings.index.blocks.write: "true" }
92+
- match: { default-copy-settings-target.settings.index.routing.allocation.include._id: $master }
9393

9494
# now we do a actual shrink and try to set no copy settings
9595
- do:

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ setup:
3333
---
3434
"Split index via API":
3535
- skip:
36-
version: " - 6.3.99"
37-
reason: expects warnings that pre-6.4.0 will not send
36+
version: " - 6.9.99"
37+
reason: pre-7.0.0 will send warnings
3838
features: "warnings"
3939

4040
# make it read-only
@@ -61,8 +61,6 @@ setup:
6161
settings:
6262
index.number_of_replicas: 0
6363
index.number_of_shards: 4
64-
warnings:
65-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
6664

6765
- do:
6866
cluster.health:
@@ -108,8 +106,7 @@ setup:
108106
"Split from 1 to N":
109107
- skip:
110108
version: " - 6.99.99"
111-
reason: Automatic preparation for splitting was added in 7.0.0
112-
features: "warnings"
109+
reason: automatic preparation for splitting was added in 7.0.0
113110
- do:
114111
indices.create:
115112
index: source_one_shard
@@ -163,8 +160,6 @@ setup:
163160
settings:
164161
index.number_of_replicas: 0
165162
index.number_of_shards: 5
166-
warnings:
167-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
168163

169164
- do:
170165
cluster.health:
@@ -205,13 +200,11 @@ setup:
205200
- match: { _id: "3" }
206201
- match: { _source: { foo: "hello world 3" } }
207202

208-
209-
210203
---
211204
"Create illegal split indices":
212205
- skip:
213-
version: " - 6.3.99"
214-
reason: expects warnings that pre-6.4.0 will not send
206+
version: " - 6.9.99"
207+
reason: pre-7.0.0 will send warnings
215208
features: "warnings"
216209

217210
# try to do an illegal split with number_of_routing_shards set
@@ -227,8 +220,6 @@ setup:
227220
index.number_of_replicas: 0
228221
index.number_of_shards: 4
229222
index.number_of_routing_shards: 8
230-
warnings:
231-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
232223

233224
# try to do an illegal split with illegal number_of_shards
234225
- do:
@@ -242,5 +233,3 @@ setup:
242233
settings:
243234
index.number_of_replicas: 0
244235
index.number_of_shards: 6
245-
warnings:
246-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"

rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/20_source_mapping.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
"Split index ignores target template mapping":
33
- skip:
4-
version: " - 6.3.99"
5-
reason: expects warnings that pre-6.4.0 will not send
4+
version: " - 6.9.99"
5+
reason: pre-7.0.0 will send warnings
66
features: "warnings"
77

88
# create index
@@ -65,8 +65,6 @@
6565
settings:
6666
index.number_of_shards: 2
6767
index.number_of_replicas: 0
68-
warnings:
69-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
7068

7169
- do:
7270
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/30_copy_settings.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
"Copy settings during split index":
33
- skip:
4-
version: " - 6.3.99"
5-
reason: expects warnings that pre-6.4.0 will not send
4+
version: " - 6.9.99"
5+
reason: expects warnings that pre-7.0.0 will not send
66
features: "warnings"
77

88
- do:
@@ -50,6 +50,9 @@
5050
index.number_of_replicas: 0
5151
index.number_of_shards: 2
5252
index.merge.scheduler.max_thread_count: 2
53+
warnings:
54+
- "parameter [copy_settings] is deprecated and will be removed in 8.0.0"
55+
5356

5457
- do:
5558
cluster.health:
@@ -65,34 +68,32 @@
6568
- match: { copy-settings-target.settings.index.blocks.write: "true" }
6669
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
6770

68-
# now we do a actual shrink and do not copy settings (by default)
71+
# now we do a actual shrink and copy settings (by default)
6972
- do:
7073
indices.split:
7174
index: "source"
72-
target: "no-copy-settings-target"
75+
target: "default-copy-settings-target"
7376
wait_for_active_shards: 1
7477
master_timeout: 10s
7578
body:
7679
settings:
7780
index.number_of_replicas: 0
7881
index.number_of_shards: 2
7982
index.merge.scheduler.max_thread_count: 2
80-
warnings:
81-
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
8283

8384
- do:
8485
cluster.health:
8586
wait_for_status: green
8687

8788
- do:
8889
indices.get_settings:
89-
index: "no-copy-settings-target"
90+
index: "default-copy-settings-target"
9091

91-
# only the request setting should be copied
92-
- is_false: no-copy-settings-target.settings.index.merge.scheduler.max_merge_count
93-
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
94-
- is_false: no-copy-settings-target.settings.index.blocks.write
95-
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id
92+
# settings should be copied
93+
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" }
94+
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
95+
- match: { default-copy-settings-target.settings.index.blocks.write: "true" }
96+
- match: { default-copy-settings-target.settings.index.routing.allocation.include._id: $master }
9697

9798
- do:
9899
catch: /illegal_argument_exception/

server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class ResizeRequest extends AcknowledgedRequest<ResizeRequest> implements
5656
private CreateIndexRequest targetIndexRequest;
5757
private String sourceIndex;
5858
private ResizeType type = ResizeType.SHRINK;
59-
private Boolean copySettings;
59+
private Boolean copySettings = true;
6060

6161
ResizeRequest() {}
6262

0 commit comments

Comments
 (0)