Skip to content
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

Adding number of routing shards to index settings before passing into… #14446

Closed
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix fs info reporting negative available size ([#11573](https://github.com/opensearch-project/OpenSearch/pull/11573))
- Add ListPitInfo::getKeepAlive() getter ([#14495](https://github.com/opensearch-project/OpenSearch/pull/14495))
- Fix FuzzyQuery in keyword field will use IndexOrDocValuesQuery when both of index and doc_value are true ([#14378](https://github.com/opensearch-project/OpenSearch/pull/14378))
- Updated GET {index}/_settings to return `number_of_routing_shards` ([#14446](https://github.com/opensearch-project/OpenSearch/pull/14446))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,42 @@ setup:

- is_true: test_1
- is_true: test_2

---
"Test number of routing shards returned":
- skip:
version: " - 2.99.99"
reason: "introduced in 3.0.0"

- do:
indices.create:
index: test_3
body:
settings:
number_of_shards: 3
number_of_replicas: 0
number_of_routing_shards: 6

- do:
indices.get_settings: {}

- match: { test_3.settings.index.number_of_shards: "3"}
- match: { test_3.settings.index.number_of_replicas: "0"}
- match: { test_3.settings.index.number_of_routing_shards: "6"}

- do:
indices.get_settings:
index: test_3

- match: { test_3.settings.index.number_of_shards: "3"}
- match: { test_3.settings.index.number_of_replicas: "0"}
- match: { test_3.settings.index.number_of_routing_shards: "6"}

- do:
indices.get_settings:
index: test_3
name: _all

- match: { test_3.settings.index.number_of_shards: "3"}
- match: { test_3.settings.index.number_of_replicas: "0"}
- match: { test_3.settings.index.number_of_routing_shards: "6"}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ protected void clusterManagerOperation(GetSettingsRequest request, ClusterState
continue;
}

Settings indexSettings = settingsFilter.filter(indexMetadata.getSettings());
Settings indexSettingsWithRoutingShards = Settings.builder()
.put(indexMetadata.getSettings())
.put(IndexMetadata.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.getKey(), indexMetadata.getRoutingNumShards())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there're some unit test code for TransportGetSettingsAction in this file:

class TestTransportGetSettingsAction extends TransportGetSettingsAction {

, please also add some unit test cases for the code change in this PR, thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test case for the code change in GetSettingsActionTests

.build();

Settings indexSettings = settingsFilter.filter(indexSettingsWithRoutingShards);
if (request.humanReadable()) {
indexSettings = IndexMetadata.addHumanReadableSettings(indexSettings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ public void testIncludeDefaultsWithFiltering() {
}, exception -> { throw new AssertionError(exception); }));
}

public void testShouldReturnNumberOfRoutingShards() {
GetSettingsRequest noDefaultsRequest = new GetSettingsRequest().indices(indexName);
getSettingsAction.execute(null, noDefaultsRequest, ActionListener.wrap(noDefaultsResponse -> {
assertNotNull(
"index.number_of_routing_shards should be set",
noDefaultsResponse.getSetting(indexName, "index.number_of_routing_shards")
);
}, exception -> { throw new AssertionError(exception); }));
}

static class Resolver extends IndexNameExpressionResolver {
Resolver() {
super(new ThreadContext(Settings.EMPTY));
Expand Down
Loading