Skip to content

Commit f73f384

Browse files
committed
limit the max value of cluster.max_shards_per_node
Signed-off-by: kkewwei [email protected]
1 parent 1084ba9 commit f73f384

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7272
- Pass parent filter to inner hit query ([#13903](https://github.com/opensearch-project/OpenSearch/pull/13903))
7373
- Fix NPE on restore searchable snapshot ([#13911](https://github.com/opensearch-project/OpenSearch/pull/13911))
7474
- Fix double invocation of postCollection when MultiBucketCollector is present ([#14015](https://github.com/opensearch-project/OpenSearch/pull/14015))
75+
- Fix limit the max value of cluster.max_shards_per_node to avoid int overflow ([#14155](https://github.com/opensearch-project/OpenSearch/pull/14155))
7576

7677
### Security
7778

server/src/main/java/org/opensearch/indices/ShardLimitValidator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class ShardLimitValidator {
6868
"cluster.max_shards_per_node",
6969
1000,
7070
1,
71+
1_500_000,
7172
new MaxShardPerNodeLimitValidator(),
7273
Setting.Property.Dynamic,
7374
Setting.Property.NodeScope

server/src/test/java/org/opensearch/indices/ShardLimitValidatorTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ public void testNonSystemIndexCreationFailsWithMaxShardLimitOnCluster() {
214214
);
215215
}
216216

217+
public void testMaxValueOfMaxShardLimitOnCluster() {
218+
final int maxShardLimitOnCluster = 2_000_000;
219+
Settings limitOnlySettings = Settings.builder().put(SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), maxShardLimitOnCluster).build();
220+
final IllegalArgumentException exception = expectThrows(
221+
IllegalArgumentException.class,
222+
() -> createTestShardLimitService(limitOnlySettings)
223+
);
224+
assertEquals(
225+
"Failed to parse value [" + maxShardLimitOnCluster + "] for setting [cluster.max_shards_per_node] must be <= 1500000",
226+
exception.getMessage()
227+
);
228+
229+
}
230+
217231
public void testNonSystemIndexCreationPassesWithMaxShardLimitOnCluster() {
218232
final int maxShardLimitOnCluster = 5;
219233
Settings limitOnlySettings = Settings.builder()

0 commit comments

Comments
 (0)