Skip to content

Commit e2f2ac3

Browse files
Remove index blocks by default in create_from (#120643)
Change the default value for the `remove_index_blocks` parameter of the `_create_from` api to true. This means that when a source index has blocks, by default these blocks will be filtered out when creating the destination index.
1 parent fdab1ff commit e2f2ac3

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

docs/changelog/120643.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120643
2+
summary: Remove index blocks by default in `create_from`
3+
area: Indices APIs
4+
type: enhancement
5+
issues: []

x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/xpack/migrate/action/CreateIndexFromSourceActionIT.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public void testSettingsNullOverride() throws Exception {
222222
assertNull(destSettings.get(IndexMetadata.SETTING_BLOCKS_WRITE));
223223
}
224224

225-
public void testRemoveIndexBlocks() throws Exception {
225+
public void testRemoveIndexBlocksByDefault() throws Exception {
226226
assumeTrue("requires the migration reindex feature flag", REINDEX_DATA_STREAM_FEATURE_FLAG.isEnabled());
227227

228228
var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
@@ -241,12 +241,10 @@ public void testRemoveIndexBlocks() throws Exception {
241241

242242
// create from source
243243
var destIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
244-
assertAcked(
245-
client().execute(
246-
CreateIndexFromSourceAction.INSTANCE,
247-
new CreateIndexFromSourceAction.Request(sourceIndex, destIndex, settingsOverride, Map.of(), true)
248-
)
249-
);
244+
245+
CreateIndexFromSourceAction.Request request = new CreateIndexFromSourceAction.Request(sourceIndex, destIndex);
246+
request.settingsOverride(settingsOverride);
247+
assertAcked(client().execute(CreateIndexFromSourceAction.INSTANCE, request));
250248

251249
// assert settings overridden
252250
var settingsResponse = indicesAdmin().getSettings(new GetSettingsRequest().indices(destIndex)).actionGet();

x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/CreateIndexFromSourceAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static class Request extends ActionRequest implements IndicesRequest, ToX
6565
}
6666

6767
public Request(String sourceIndex, String destIndex) {
68-
this(sourceIndex, destIndex, Settings.EMPTY, Map.of(), false);
68+
this(sourceIndex, destIndex, Settings.EMPTY, Map.of(), true);
6969
}
7070

7171
public Request(

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migrate/30_create_from.yml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,40 @@ teardown:
120120
- match: {dest-index-1.mappings.properties.baz.type: integer}
121121

122122
---
123-
"Test create_from with remove_index_blocks":
123+
"Test create_from with remove_index_blocks set to false":
124+
- requires:
125+
reason: "migration reindex is behind a feature flag"
126+
test_runner_features: [capabilities]
127+
capabilities:
128+
- method: POST
129+
path: /_migration/reindex
130+
capabilities: [migration_reindex]
131+
- do:
132+
indices.create:
133+
index: source-index-1
134+
body:
135+
settings:
136+
index:
137+
blocks.write: true
138+
blocks.read: true
139+
- do:
140+
migrate.create_from:
141+
source: "source-index-1"
142+
dest: "dest-index-1"
143+
body:
144+
settings_override:
145+
index:
146+
blocks.write: false
147+
blocks.read: true
148+
remove_index_blocks: false
149+
- do:
150+
indices.get_settings:
151+
index: dest-index-1
152+
- match: { dest-index-1.settings.index.blocks.write: "false" }
153+
- match: { dest-index-1.settings.index.blocks.read: "true" }
154+
155+
---
156+
"Test create_from with remove_index_blocks default of true":
124157
- requires:
125158
reason: "migration reindex is behind a feature flag"
126159
test_runner_features: [capabilities]
@@ -136,8 +169,6 @@ teardown:
136169
index:
137170
blocks.write: true
138171
blocks.read: true
139-
number_of_shards: 1
140-
number_of_replicas: 0
141172
- do:
142173
indices.create_from:
143174
source: "source-index-1"
@@ -147,11 +178,9 @@ teardown:
147178
index:
148179
blocks.write: false
149180
blocks.read: true
150-
remove_index_blocks: true
151181
- do:
152182
indices.get_settings:
153183
index: dest-index-1
154-
- match: { dest-index-1.settings.index.number_of_shards: "1" }
155184
- match: { dest-index-1.settings.index.blocks.write: null }
156185
- match: { dest-index-1.settings.index.blocks.read: null }
157186

0 commit comments

Comments
 (0)