Skip to content

Commit

Permalink
Fix bwc for cluster manager throttling settings (opensearch-project#5305
Browse files Browse the repository at this point in the history
)

Signed-off-by: Dhwanil Patel <dhwanip@amazon.com>
  • Loading branch information
dhwanilpatel authored and ryanbogan committed Dec 12, 2022
1 parent 1853ffb commit ccabf8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ public boolean isThrottlingEnabled() {
}

void validateSetting(final Settings settings) {
if (minNodeVersionSupplier.get().compareTo(Version.V_2_4_0) < 0) {
throw new IllegalArgumentException("All the nodes in cluster should be on version later than or equal to 2.4.0");
}
Map<String, Settings> groups = settings.getAsGroups();
if (groups.size() > 0) {
if (minNodeVersionSupplier.get().compareTo(Version.V_2_4_0) < 0) {
throw new IllegalArgumentException("All the nodes in cluster should be on version later than or equal to 2.4.0");
}
}
for (String key : groups.keySet()) {
if (!THROTTLING_TASK_KEYS.containsKey(key)) {
throw new IllegalArgumentException("Cluster manager task throttling is not configured for given task type: " + key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ public void testValidateSettingsForDifferentVersion() {

Settings newSettings = Settings.builder().put("cluster_manager.throttling.thresholds.put-mapping.value", newLimit).build();
assertThrows(IllegalArgumentException.class, () -> throttler.validateSetting(newSettings));

// validate for empty setting, it shouldn't throw exception
Settings emptySettings = Settings.builder().build();
try {
throttler.validateSetting(emptySettings);
} catch (Exception e) {
// it shouldn't throw exception
throw new AssertionError(e);
}
}

public void testValidateSettingsForTaskWihtoutRetryOnDataNode() {
Expand Down

0 comments on commit ccabf8c

Please sign in to comment.