-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Disabled auto_expand_replicas setting when search replica is enabled #16916
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c6a1d64
Disabled auto_expand_replicas setting when search replica is enabled
vinaykpud 03ea0e9
Merge branch 'main' into disable-auto-expand
vinaykpud 52f6ca8
Added integration test
vinaykpud 5ae03df
Merge branch 'main' into disable-auto-expand
vinaykpud ed29ddd
Fixed PR commits from mch2
vinaykpud 2f14b02
Merge branch 'main' into disable-auto-expand
vinaykpud 459d00b
Fixed integration tests
vinaykpud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...ternalClusterTest/java/org/opensearch/cluster/metadata/AutoExpandWithSearchReplicaIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.cluster.metadata; | ||
|
|
||
| import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse; | ||
| import org.opensearch.common.settings.Settings; | ||
| import org.opensearch.common.util.FeatureFlags; | ||
| import org.opensearch.indices.replication.common.ReplicationType; | ||
| import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
|
||
| public class AutoExpandWithSearchReplicaIT extends OpenSearchIntegTestCase { | ||
|
|
||
| private static final String INDEX_NAME = "test-idx-1"; | ||
|
|
||
| @Override | ||
| protected Settings featureFlagSettings() { | ||
| return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.READER_WRITER_SPLIT_EXPERIMENTAL, true).build(); | ||
| } | ||
|
|
||
| public void testEnableAutoExpandWhenSearchReplicaActive() { | ||
| internalCluster().startDataOnlyNodes(3); | ||
| createIndex( | ||
| INDEX_NAME, | ||
| Settings.builder() | ||
| .put("number_of_shards", 1) | ||
| .put("number_of_replicas", 1) | ||
| .put("number_of_search_only_replicas", 1) | ||
| .put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) | ||
| .build() | ||
| ); | ||
| ensureGreen(INDEX_NAME); | ||
|
|
||
| expectThrows(IllegalArgumentException.class, () -> { | ||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.auto_expand_replicas", "0-1")) | ||
| .execute() | ||
| .actionGet(); | ||
| }); | ||
|
|
||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.number_of_search_only_replicas", "0")) | ||
| .execute() | ||
| .actionGet(); | ||
|
|
||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.auto_expand_replicas", "0-1")) | ||
| .execute() | ||
| .actionGet(); | ||
|
|
||
| GetSettingsResponse response = client().admin().indices().prepareGetSettings(INDEX_NAME).execute().actionGet(); | ||
|
|
||
| assertEquals("0-1", response.getSetting(INDEX_NAME, "index.auto_expand_replicas")); | ||
| } | ||
|
|
||
| public void testEnableSearchReplicaWithAutoExpandActive() { | ||
| internalCluster().startDataOnlyNodes(3); | ||
| createIndex( | ||
| INDEX_NAME, | ||
| Settings.builder() | ||
| .put("number_of_shards", 1) | ||
| .put("number_of_replicas", 1) | ||
| .put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) | ||
| .build() | ||
| ); | ||
| ensureGreen(INDEX_NAME); | ||
|
|
||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.auto_expand_replicas", "0-1")) | ||
| .execute() | ||
| .actionGet(); | ||
|
|
||
| expectThrows(IllegalArgumentException.class, () -> { | ||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.number_of_search_only_replicas", "1")) | ||
| .execute() | ||
| .actionGet(); | ||
| }); | ||
|
|
||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.auto_expand_replicas", false)) | ||
| .execute() | ||
| .actionGet(); | ||
|
|
||
| client().admin() | ||
| .indices() | ||
| .prepareUpdateSettings(INDEX_NAME) | ||
| .setSettings(Settings.builder().put("index.number_of_search_only_replicas", "1")) | ||
| .execute() | ||
| .actionGet(); | ||
|
|
||
| GetSettingsResponse response = client().admin().indices().prepareGetSettings(INDEX_NAME).execute().actionGet(); | ||
|
|
||
| assertEquals("1", response.getSetting(INDEX_NAME, "index.number_of_search_only_replicas")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...t/java/org/opensearch/cluster/metadata/DisableAutoExpandReplicaForSearchReplicaTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.cluster.metadata; | ||
|
|
||
| import org.opensearch.common.settings.Settings; | ||
| import org.opensearch.test.OpenSearchTestCase; | ||
|
|
||
| /** | ||
| * AutoExpandReplica Disabled for Search Replica | ||
| */ | ||
| public class DisableAutoExpandReplicaForSearchReplicaTests extends OpenSearchTestCase { | ||
|
|
||
| public void testWhenAutoExpandReplicaAndSearchReplicaIsSetInTheRequest() { | ||
| Settings conflictRequestSettings = Settings.builder() | ||
| .put("index.number_of_search_only_replicas", 1) | ||
| .put("index.auto_expand_replicas", "0-all") | ||
| .build(); | ||
|
|
||
| assertEquals( | ||
| "Cannot set both [index.auto_expand_replicas] and [index.number_of_search_only_replicas]. These settings are mutually exclusive.", | ||
| MetadataCreateIndexService.validateAutoExpandReplicaConflictInRequest(conflictRequestSettings).get() | ||
| ); | ||
| } | ||
|
|
||
| public void testWhenOnlyAutoExpandReplicaIsSetInTheRequest() { | ||
| Settings reqestSettings = Settings.builder() | ||
| .put("index.number_of_search_only_replicas", 0) | ||
| .put("index.auto_expand_replicas", "0-all") | ||
| .build(); | ||
|
|
||
| assertTrue(MetadataCreateIndexService.validateAutoExpandReplicaConflictInRequest(reqestSettings).isEmpty()); | ||
| } | ||
|
|
||
| public void testWhenAutoExpandReplicaEnabledForTheIndex() { | ||
| Settings reqestSettings = Settings.builder().put("index.number_of_search_only_replicas", 1).build(); | ||
|
|
||
| Settings indexSettings = Settings.builder().put("index.auto_expand_replicas", "0-all").build(); | ||
|
|
||
| assertEquals( | ||
| "Cannot set [index.number_of_search_only_replicas] because [index.auto_expand_replicas] is configured. These settings are mutually exclusive.", | ||
| MetadataCreateIndexService.validateAutoExpandReplicaConflictWithIndex(reqestSettings, indexSettings).get() | ||
| ); | ||
| } | ||
|
|
||
| public void testWhenSearchReplicaEnabledForTheIndex() { | ||
| Settings reqestSettings = Settings.builder().put("index.auto_expand_replicas", "0-all").build(); | ||
|
|
||
| Settings indexSettings = Settings.builder().put("index.number_of_search_only_replicas", 1).build(); | ||
|
|
||
| assertEquals( | ||
| "Cannot set [index.auto_expand_replicas] because [index.number_of_search_only_replicas] is set. These settings are mutually exclusive.", | ||
| MetadataCreateIndexService.validateAutoExpandReplicaConflictWithIndex(reqestSettings, indexSettings).get() | ||
| ); | ||
| } | ||
|
|
||
| public void testWhenSearchReplicaSetZeroForTheIndex() { | ||
| Settings reqestSettings = Settings.builder().put("index.auto_expand_replicas", "0-all").build(); | ||
|
|
||
| Settings indexSettings = Settings.builder().put("index.number_of_search_only_replicas", 0).build(); | ||
|
|
||
| assertTrue(MetadataCreateIndexService.validateAutoExpandReplicaConflictWithIndex(reqestSettings, indexSettings).isEmpty()); | ||
| } | ||
|
|
||
| public void testIfSearchReplicaEnabledEnablingAutoExpandReplicasAndDisablingSearchReplicasNotPossibleInSingleRequest() { | ||
| Settings reqestSettings = Settings.builder() | ||
| .put("index.auto_expand_replicas", "0-all") | ||
| .put("index.number_of_search_only_replicas", 0) | ||
| .build(); | ||
|
|
||
| Settings indexSettings = Settings.builder().put("index.number_of_search_only_replicas", 1).build(); | ||
|
|
||
| assertEquals( | ||
| "Cannot set [index.auto_expand_replicas] because [index.number_of_search_only_replicas] " | ||
| + "is set. These settings are mutually exclusive.", | ||
| MetadataCreateIndexService.validateAutoExpandReplicaConflictWithIndex(reqestSettings, indexSettings).get() | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.