Skip to content

Commit

Permalink
Adding number of routing shards to index settings before passing into…
Browse files Browse the repository at this point in the history
… GetSettingsResponse

Signed-off-by: Sophia <tjdud6024@gmail.com>
  • Loading branch information
Sophia committed Jun 25, 2024
1 parent afad5eb commit 02bd802
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
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())
.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

0 comments on commit 02bd802

Please sign in to comment.