Skip to content

Remove index blocks by default in create_from #120643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/120643.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 120643
summary: Remove index blocks by default in `create_from`
area: Indices APIs
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void testSettingsNullOverride() throws Exception {
assertNull(destSettings.get(IndexMetadata.SETTING_BLOCKS_WRITE));
}

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

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

// create from source
var destIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
assertAcked(
client().execute(
CreateIndexFromSourceAction.INSTANCE,
new CreateIndexFromSourceAction.Request(sourceIndex, destIndex, settingsOverride, Map.of(), true)
)
);

CreateIndexFromSourceAction.Request request = new CreateIndexFromSourceAction.Request(sourceIndex, destIndex);
request.settingsOverride(settingsOverride);
assertAcked(client().execute(CreateIndexFromSourceAction.INSTANCE, request));

// assert settings overridden
var settingsResponse = indicesAdmin().getSettings(new GetSettingsRequest().indices(destIndex)).actionGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static class Request extends ActionRequest implements IndicesRequest, ToX
}

public Request(String sourceIndex, String destIndex) {
this(sourceIndex, destIndex, Settings.EMPTY, Map.of(), false);
this(sourceIndex, destIndex, Settings.EMPTY, Map.of(), true);
}

public Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,40 @@ teardown:
- match: {dest-index-1.mappings.properties.baz.type: integer}

---
"Test create_from with remove_index_blocks":
"Test create_from with remove_index_blocks set to false":
- requires:
reason: "migration reindex is behind a feature flag"
test_runner_features: [capabilities]
capabilities:
- method: POST
path: /_migration/reindex
capabilities: [migration_reindex]
- do:
indices.create:
index: source-index-1
body:
settings:
index:
blocks.write: true
blocks.read: true
- do:
migrate.create_from:
source: "source-index-1"
dest: "dest-index-1"
body:
settings_override:
index:
blocks.write: false
blocks.read: true
remove_index_blocks: false
- do:
indices.get_settings:
index: dest-index-1
- match: { dest-index-1.settings.index.blocks.write: "false" }
- match: { dest-index-1.settings.index.blocks.read: "true" }

---
"Test create_from with remove_index_blocks default of true":
- requires:
reason: "migration reindex is behind a feature flag"
test_runner_features: [capabilities]
Expand All @@ -136,8 +169,6 @@ teardown:
index:
blocks.write: true
blocks.read: true
number_of_shards: 1
number_of_replicas: 0
- do:
migrate.create_from:
source: "source-index-1"
Expand All @@ -147,11 +178,9 @@ teardown:
index:
blocks.write: false
blocks.read: true
remove_index_blocks: true
- do:
indices.get_settings:
index: dest-index-1
- match: { dest-index-1.settings.index.number_of_shards: "1" }
- match: { dest-index-1.settings.index.blocks.write: null }
- match: { dest-index-1.settings.index.blocks.read: null }