From 10493ee250f89705e8d757bace85c7f6b295ac71 Mon Sep 17 00:00:00 2001 From: Sandesh Kumar Date: Fri, 24 Mar 2023 13:37:20 -0700 Subject: [PATCH] Override isEnabledByDefault() for cluster manager role Signed-off-by: Sandesh Kumar --- .../java/org/opensearch/cluster/node/DiscoveryNode.java | 9 +-------- .../org/opensearch/cluster/node/DiscoveryNodeRole.java | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java index 215591b0823f7..02b4c5451de67 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java @@ -285,14 +285,7 @@ public static Set getRolesFromSettings(final Settings setting validateLegacySettings(settings, roleMap); return Collections.unmodifiableSet(new HashSet<>(NODE_ROLES_SETTING.get(settings))); } else { - return roleMap.values() - .stream() - .filter( - s -> !s.roleName().equals(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName()) - && s.legacySetting() != null - && s.legacySetting().get(settings) - ) - .collect(Collectors.toSet()); + return roleMap.values().stream().filter(s -> s.isEnabledByDefault(settings)).collect(Collectors.toSet()); } } diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java index 31dab23c0706d..afa43434aca0a 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java @@ -34,6 +34,7 @@ import org.opensearch.LegacyESVersion; import org.opensearch.Version; +import org.opensearch.common.Booleans; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; @@ -275,7 +276,7 @@ public void validateRole(List roles) { @Override public boolean isEnabledByDefault(final Settings settings) { - return settings.getAsBoolean("node.master", true); + return !Booleans.isBoolean(settings.get("node.master")); } };