Skip to content

Commit 913cb3a

Browse files
authored
Fix bwc for cluster manager throttling settings (opensearch-project#5305)
Signed-off-by: Dhwanil Patel <[email protected]>
1 parent 0bd3141 commit 913cb3a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

server/src/main/java/org/opensearch/cluster/service/ClusterManagerTaskThrottler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ public boolean isThrottlingEnabled() {
108108
}
109109

110110
void validateSetting(final Settings settings) {
111-
if (minNodeVersionSupplier.get().compareTo(Version.V_2_4_0) < 0) {
112-
throw new IllegalArgumentException("All the nodes in cluster should be on version later than or equal to 2.4.0");
113-
}
114111
Map<String, Settings> groups = settings.getAsGroups();
112+
if (groups.size() > 0) {
113+
if (minNodeVersionSupplier.get().compareTo(Version.V_2_4_0) < 0) {
114+
throw new IllegalArgumentException("All the nodes in cluster should be on version later than or equal to 2.4.0");
115+
}
116+
}
115117
for (String key : groups.keySet()) {
116118
if (!THROTTLING_TASK_KEYS.containsKey(key)) {
117119
throw new IllegalArgumentException("Cluster manager task throttling is not configured for given task type: " + key);

server/src/test/java/org/opensearch/cluster/service/ClusterManagerTaskThrottlerTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ public void testValidateSettingsForDifferentVersion() {
114114

115115
Settings newSettings = Settings.builder().put("cluster_manager.throttling.thresholds.put-mapping.value", newLimit).build();
116116
assertThrows(IllegalArgumentException.class, () -> throttler.validateSetting(newSettings));
117+
118+
// validate for empty setting, it shouldn't throw exception
119+
Settings emptySettings = Settings.builder().build();
120+
try {
121+
throttler.validateSetting(emptySettings);
122+
} catch (Exception e) {
123+
// it shouldn't throw exception
124+
throw new AssertionError(e);
125+
}
117126
}
118127

119128
public void testValidateSettingsForTaskWihtoutRetryOnDataNode() {

0 commit comments

Comments
 (0)