From 306e6a900a429dbdd7c657cb7e5a30609e521d2d Mon Sep 17 00:00:00 2001 From: Sandesh Kumar Date: Fri, 24 Mar 2023 12:30:42 -0700 Subject: [PATCH] Fix role filtering from legacy settings Signed-off-by: Sandesh Kumar --- .../java/org/opensearch/cluster/node/DiscoveryNode.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 02b4c5451de67..215591b0823f7 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java @@ -285,7 +285,14 @@ 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.isEnabledByDefault(settings)).collect(Collectors.toSet()); + return roleMap.values() + .stream() + .filter( + s -> !s.roleName().equals(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName()) + && s.legacySetting() != null + && s.legacySetting().get(settings) + ) + .collect(Collectors.toSet()); } }