diff --git a/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 982f35862dc80..c7fc74eb6902b 100644 --- a/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -212,7 +212,10 @@ public static DiscoveryNode createLocal(Settings settings, TransportAddress publ /** extract node roles from the given settings */ public static Set getRolesFromSettings(final Settings settings) { - if (NODE_ROLES_SETTING.exists(settings)) { + // are any legacy settings in use? + boolean usesLegacySettings = + getPossibleRoles().stream().anyMatch(s -> s.legacySetting() != null && s.legacySetting().exists(settings)); + if (NODE_ROLES_SETTING.exists(settings) || usesLegacySettings == false) { validateLegacySettings(settings, roleMap); return Set.copyOf(NODE_ROLES_SETTING.get(settings)); } else { diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 9c44eea0052be..b596e57274194 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -37,11 +37,11 @@ import org.elasticsearch.cluster.NodeConnectionsService; import org.elasticsearch.cluster.action.index.MappingUpdatedAction; import org.elasticsearch.cluster.metadata.AliasValidator; +import org.elasticsearch.cluster.metadata.IndexMetadataVerifier; import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.MetadataCreateDataStreamService; import org.elasticsearch.cluster.metadata.MetadataCreateIndexService; -import org.elasticsearch.cluster.metadata.IndexMetadataVerifier; import org.elasticsearch.cluster.metadata.SystemIndexMetadataUpgradeService; import org.elasticsearch.cluster.metadata.TemplateUpgradeService; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -338,11 +338,36 @@ protected Node(final Environment initialEnvironment, this.environment = new Environment(settings, initialEnvironment.configFile()); Environment.assertEquivalent(initialEnvironment, this.environment); nodeEnvironment = new NodeEnvironment(tmpSettings, environment); - logger.info("node name [{}], node ID [{}], cluster name [{}], roles {}", - NODE_NAME_SETTING.get(tmpSettings), nodeEnvironment.nodeId(), ClusterName.CLUSTER_NAME_SETTING.get(tmpSettings).value(), - DiscoveryNode.getRolesFromSettings(settings).stream() - .map(DiscoveryNodeRole::roleName) - .collect(Collectors.toCollection(LinkedHashSet::new))); + final Set roleNames = DiscoveryNode.getRolesFromSettings(settings).stream() + .map(DiscoveryNodeRole::roleName) + .collect(Collectors.toCollection(LinkedHashSet::new)); + logger.info( + "node name [{}], node ID [{}], cluster name [{}], roles {}", + NODE_NAME_SETTING.get(tmpSettings), + nodeEnvironment.nodeId(), + ClusterName.CLUSTER_NAME_SETTING.get(tmpSettings).value(), + roleNames + ); + { + // are there any legacy settings in use? + final List> maybeLegacyRoleSettings = DiscoveryNode.getPossibleRoles() + .stream() + .filter(s -> s.legacySetting() != null) + .map(DiscoveryNodeRole::legacySetting) + .filter(s -> s.exists(settings)) + .collect(Collectors.toUnmodifiableList()); + if (maybeLegacyRoleSettings.isEmpty() == false) { + final String legacyRoleSettingNames = + maybeLegacyRoleSettings.stream().map(Setting::getKey).collect(Collectors.joining(", ")); + deprecationLogger.deprecate( + DeprecationCategory.SETTINGS, + "legacy role settings", + "legacy role settings [{}] are deprecated, use [node.roles={}]", + legacyRoleSettingNames, + roleNames + ); + } + } resourcesToClose.add(nodeEnvironment); localNodeFactory = new LocalNodeFactory(settings, nodeEnvironment.nodeId());