Skip to content

Commit 593fdd4

Browse files
authored
Deprecate not copy settings and explicitly disallow (#30404)
We want copying settings to be the default behavior. This commit deprecates not copying settings, and disallows explicitly not copying settings. This gives users a transition path to the future default behavior.
1 parent 9dd6296 commit 593fdd4

File tree

14 files changed

+177
-63
lines changed

14 files changed

+177
-63
lines changed

docs/CHANGELOG.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ analysis module. ({pull}30397[#30397])
163163
[float]
164164
=== Enhancements
165165

166-
{ref-64}/breaking_64_api_changes.html#copy-source-settings-on-resize[Allow copying source settings on index resize operations] ({pull}30255[#30255])
166+
{ref-64}/breaking_64_api_changes.html#copy-source-settings-on-resize[Allow
167+
copying source settings on index resize operations] ({pull}30255[#30255], {pull}30404[#30404])
167168

168169
Added new "Request" object flavored request methods in the RestClient. Prefer
169170
these instead of the multi-argument versions. ({pull}29623[#29623])

docs/reference/indices/shrink-index.asciidoc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,20 @@ the following request:
6262

6363
[source,js]
6464
--------------------------------------------------
65-
POST my_source_index/_shrink/my_target_index
65+
POST my_source_index/_shrink/my_target_index?copy_settings=true
66+
{
67+
"settings": {
68+
"index.routing.allocation.require._name": null, <1>
69+
"index.blocks.write": null <2>
70+
}
71+
}
6672
--------------------------------------------------
6773
// CONSOLE
6874
// TEST[continued]
6975

76+
<1> Clear the allocation requirement copied from the source index.
77+
<2> Clear the index write block copied from the source index.
78+
7079
The above request returns immediately once the target index has been added to
7180
the cluster state -- it doesn't wait for the shrink operation to start.
7281

@@ -97,7 +106,7 @@ and accepts `settings` and `aliases` parameters for the target index:
97106

98107
[source,js]
99108
--------------------------------------------------
100-
POST my_source_index/_shrink/my_target_index
109+
POST my_source_index/_shrink/my_target_index?copy_settings=true
101110
{
102111
"settings": {
103112
"index.number_of_replicas": 1,
@@ -125,9 +134,11 @@ NOTE: By default, with the exception of `index.analysis`, `index.similarity`,
125134
and `index.sort` settings, index settings on the source index are not copied
126135
during a shrink operation. With the exception of non-copyable settings, settings
127136
from the source index can be copied to the target index by adding the URL
128-
parameter `copy_settings=true` to the request.
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 9.0.0
129139

130-
deprecated[6.4.0, `copy_settings` will default to `true` in 8.x and will be removed in 9.0.0]
140+
deprecated[6.4.0, not copying settings is deprecated, copying settings will be
141+
the default behavior in 8.x]
131142

132143
[float]
133144
=== Monitoring the shrink process

docs/reference/indices/split-index.asciidoc

Lines changed: 6 additions & 4 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
126+
POST my_source_index/_split/my_target_index?copy_settings=true
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
161+
POST my_source_index/_split/my_target_index?copy_settings=true
162162
{
163163
"settings": {
164164
"index.number_of_shards": 5 <1>
@@ -181,9 +181,11 @@ NOTE: By default, with the exception of `index.analysis`, `index.similarity`,
181181
and `index.sort` settings, index settings on the source index are not copied
182182
during a split operation. With the exception of non-copyable settings, settings
183183
from the source index can be copied to the target index by adding the URL
184-
parameter `copy_settings=true` to the request.
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 9.0.0
185186

186-
deprecated[6.4.0, `copy_settings` will default to `true` in 8.x and will be removed in 9.0.0]
187+
deprecated[6.4.0, not copying settings is deprecated, copying settings will be
188+
the default behavior in 8.x]
187189

188190
[float]
189191
=== Monitoring the split process

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
22
"Shrink index via API":
3+
- skip:
4+
version: " - 6.99.99"
5+
reason: expects warnings that pre-7.0.0 will not send
6+
features: "warnings"
37
# creates an index with one document solely allocated on the master node
48
# and shrinks it into a new index with a single shard
59
# we don't do the relocation to a single node after the index is created
@@ -62,6 +66,8 @@
6266
body:
6367
settings:
6468
index.number_of_replicas: 0
69+
warnings:
70+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
6571

6672
- do:
6773
cluster.health:

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
"Shrink index ignores target template mapping":
3+
- skip:
4+
version: " - 6.99.99"
5+
reason: expects warnings that pre-7.0.0 will not send
6+
features: "warnings"
7+
38
- do:
49
cluster.state: {}
510
# Get master node id
@@ -65,6 +70,8 @@
6570
body:
6671
settings:
6772
index.number_of_replicas: 0
73+
warnings:
74+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
6875

6976
- do:
7077
cluster.health:

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

Lines changed: 17 additions & 7 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: copy_settings did not exist prior to 6.4.0
4+
version: " - 6.99.99"
5+
reason: expects warnings that pre-7.0.0 will not send
66
features: "warnings"
77

88
- do:
@@ -47,8 +47,6 @@
4747
settings:
4848
index.number_of_replicas: 0
4949
index.merge.scheduler.max_thread_count: 2
50-
warnings:
51-
- "parameter [copy_settings] is deprecated but was [true]"
5250

5351
- do:
5452
cluster.health:
@@ -64,20 +62,19 @@
6462
- match: { copy-settings-target.settings.index.blocks.write: "true" }
6563
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
6664

67-
# now we do a actual shrink and do not copy settings
65+
# now we do a actual shrink and do not copy settings (by default)
6866
- do:
6967
indices.shrink:
7068
index: "source"
7169
target: "no-copy-settings-target"
7270
wait_for_active_shards: 1
7371
master_timeout: 10s
74-
copy_settings: false
7572
body:
7673
settings:
7774
index.number_of_replicas: 0
7875
index.merge.scheduler.max_thread_count: 2
7976
warnings:
80-
- "parameter [copy_settings] is deprecated but was [false]"
77+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
8178

8279
- do:
8380
cluster.health:
@@ -92,3 +89,16 @@
9289
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
9390
- is_false: no-copy-settings-target.settings.index.blocks.write
9491
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id
92+
93+
# now we do a actual shrink and try to set no copy settings
94+
- do:
95+
catch: /illegal_argument_exception/
96+
indices.shrink:
97+
index: "source"
98+
target: "explicit-no-copy-settings-target"
99+
wait_for_active_shards: 1
100+
master_timeout: 10s
101+
copy_settings: false
102+
body:
103+
settings:
104+
index.number_of_replicas: 0

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ setup:
3333
---
3434
"Split index via API":
3535
- skip:
36-
version: " - 6.0.99"
37-
reason: Added in 6.1.0
36+
version: " - 6.99.99"
37+
reason: expects warnings that pre-7.0.0 will not send
38+
features: "warnings"
3839

3940
# make it read-only
4041
- do:
@@ -60,6 +61,8 @@ setup:
6061
settings:
6162
index.number_of_replicas: 0
6263
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"
6366

6467
- do:
6568
cluster.health:
@@ -103,13 +106,13 @@ setup:
103106

104107
---
105108
"Split from 1 to N":
106-
# - skip:
107-
# version: " - 6.99.99"
108-
# reason: Added in 7.0.0
109-
# uncomment once AwaitsFix is resolved
110109
- skip:
110+
# when re-enabling uncomment the below skips
111111
version: "all"
112112
reason: "AwaitsFix'ing, see https://github.com/elastic/elasticsearch/issues/30503"
113+
# version: " - 6.99.99"
114+
# reason: expects warnings that pre-7.0.0 will not send
115+
features: "warnings"
113116
- do:
114117
indices.create:
115118
index: source_one_shard
@@ -163,6 +166,8 @@ setup:
163166
settings:
164167
index.number_of_replicas: 0
165168
index.number_of_shards: 5
169+
warnings:
170+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
166171

167172
- do:
168173
cluster.health:
@@ -208,8 +213,9 @@ setup:
208213
---
209214
"Create illegal split indices":
210215
- skip:
211-
version: " - 6.0.99"
212-
reason: Added in 6.1.0
216+
version: " - 6.99.99"
217+
reason: expects warnings that pre-7.0.0 will not send
218+
features: "warnings"
213219

214220
# try to do an illegal split with number_of_routing_shards set
215221
- do:
@@ -224,6 +230,8 @@ setup:
224230
index.number_of_replicas: 0
225231
index.number_of_shards: 4
226232
index.number_of_routing_shards: 8
233+
warnings:
234+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
227235

228236
# try to do an illegal split with illegal number_of_shards
229237
- do:
@@ -237,3 +245,5 @@ setup:
237245
settings:
238246
index.number_of_replicas: 0
239247
index.number_of_shards: 6
248+
warnings:
249+
- "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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
"Split index ignores target template mapping":
3-
# - skip:
4-
# version: " - 6.0.99"
5-
# reason: Added in 6.1.0
6-
# uncomment once AwaitsFix is resolved
73
- skip:
4+
# when re-enabling uncomment the below skips
85
version: "all"
96
reason: "AwaitsFix'ing, see https://github.com/elastic/elasticsearch/issues/30503"
7+
# version: " - 6.99.99"
8+
# reason: expects warnings that pre-7.0.0 will not send
9+
features: "warnings"
1010

1111
# create index
1212
- do:
@@ -68,6 +68,8 @@
6868
settings:
6969
index.number_of_shards: 2
7070
index.number_of_replicas: 0
71+
warnings:
72+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
7173

7274
- do:
7375
cluster.health:

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

Lines changed: 16 additions & 7 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: copy_settings did not exist prior to 6.4.0
4+
version: " - 6.99.99"
5+
reason: expects warnings that pre-7.0.0 will not send
66
features: "warnings"
77

88
- do:
@@ -50,8 +50,6 @@
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 but was [true]"
5553

5654
- do:
5755
cluster.health:
@@ -67,21 +65,20 @@
6765
- match: { copy-settings-target.settings.index.blocks.write: "true" }
6866
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
6967

70-
# now we do a actual shrink and do not copy settings
68+
# now we do a actual shrink and do not copy settings (by default)
7169
- do:
7270
indices.split:
7371
index: "source"
7472
target: "no-copy-settings-target"
7573
wait_for_active_shards: 1
7674
master_timeout: 10s
77-
copy_settings: false
7875
body:
7976
settings:
8077
index.number_of_replicas: 0
8178
index.number_of_shards: 2
8279
index.merge.scheduler.max_thread_count: 2
8380
warnings:
84-
- "parameter [copy_settings] is deprecated but was [false]"
81+
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
8582

8683
- do:
8784
cluster.health:
@@ -96,3 +93,15 @@
9693
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
9794
- is_false: no-copy-settings-target.settings.index.blocks.write
9895
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id
96+
97+
- do:
98+
catch: /illegal_argument_exception/
99+
indices.split:
100+
index: "source"
101+
target: "explicit-no-copy-settings-target"
102+
wait_for_active_shards: 1
103+
master_timeout: 10s
104+
copy_settings: false
105+
body:
106+
settings:
107+
index.number_of_replicas: 0

0 commit comments

Comments
 (0)