Skip to content

Commit

Permalink
limit the max value of cluster.max_shards_per_node
Browse files Browse the repository at this point in the history
Signed-off-by: kkewwei <[email protected]>
  • Loading branch information
kkewwei committed Jun 11, 2024
1 parent 1084ba9 commit b49cd2e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Pass parent filter to inner hit query ([#13903](https://github.com/opensearch-project/OpenSearch/pull/13903))
- Fix NPE on restore searchable snapshot ([#13911](https://github.com/opensearch-project/OpenSearch/pull/13911))
- Fix double invocation of postCollection when MultiBucketCollector is present ([#14015](https://github.com/opensearch-project/OpenSearch/pull/14015))
- Fix limit the max value of cluster.max_shards_per_node to avoid int overflow ([#14155](https://github.com/opensearch-project/OpenSearch/pull/14155))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class ShardLimitValidator {
"cluster.max_shards_per_node",
1000,
1,
1_500_000,
new MaxShardPerNodeLimitValidator(),
Setting.Property.Dynamic,
Setting.Property.NodeScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ public void testNonSystemIndexCreationFailsWithMaxShardLimitOnCluster() {
);
}

public void testMaxValueOfMaxShardLimitOnCluster() {
final int maxShardLimitOnCluster = 2_000_000;
Settings limitOnlySettings = Settings.builder().put(SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), maxShardLimitOnCluster).build();
final IllegalArgumentException exception = expectThrows(
IllegalArgumentException.class,
() -> createTestShardLimitService(limitOnlySettings)
);
assertEquals(
"Failed to parse value [" + maxShardLimitOnCluster + "] for setting [cluster.max_shards_per_node] must be <= 1500000",
exception.getMessage()
);
}

public void testNonSystemIndexCreationPassesWithMaxShardLimitOnCluster() {
final int maxShardLimitOnCluster = 5;
Settings limitOnlySettings = Settings.builder()
Expand Down

0 comments on commit b49cd2e

Please sign in to comment.