Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/reference/migration/migrate_8_0/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,27 @@ If you would like to use wildcard patterns for destructive actions, set
`action.destructive_requires_name` to `false` using the <<cluster-update-settings,
cluster settings>> API.
====

.Legacy role settings are removed
[%collapsible]
====
*Details* +
The legacy role settings:

* `node.data`
* `node.ingest`
* `node.master`
* `node.ml`
* `node.remote_cluster_client`
* `node.transform`
* `node.voting_only`

have been removed. Instead, use the `node.roles` setting. If you were previously
using the legacy role settings on a 7.13 or later cluster, you will have a
deprecation log message on each of your nodes indicating the exact replacement
value for `node.roles`.

*Impact* +
Discontinue use of the removed settings. Specifying these settings in
`elasticsearch.yml` will result in an error on startup.
====
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -27,6 +28,7 @@
import java.util.function.Consumer;
import java.util.function.Function;

import static org.elasticsearch.test.NodeRoles.onlyRole;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;

Expand Down Expand Up @@ -203,10 +205,7 @@ public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exceptio

public void testWithDedicatedIngestNode() throws Exception {
String node = internalCluster().startNode();
String ingestNode = internalCluster().startNode(Settings.builder()
.put("node.master", false)
.put("node.data", false)
);
String ingestNode = internalCluster().startNode(onlyRole(DiscoveryNodeRole.INGEST_ROLE));

BytesReference pipeline = new BytesArray("{\n" +
" \"processors\" : [\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ public AdditionalRolePlugin() {
static final Setting<Boolean> NODE_ADDITIONAL_SETTING =
Setting.boolSetting("node.additional", true, Property.Deprecated, Property.NodeScope);

static DiscoveryNodeRole ADDITIONAL_ROLE = new DiscoveryNodeRole("additional", "a") {

@Override
public Setting<Boolean> legacySetting() {
return NODE_ADDITIONAL_SETTING;
}

};
static DiscoveryNodeRole ADDITIONAL_ROLE = new DiscoveryNodeRole("additional", "a");

@Override
public Set<DiscoveryNodeRole> getRoles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
Expand All @@ -49,8 +48,6 @@ public static boolean hasRole(final Settings settings, final DiscoveryNodeRole r
*/
if (settings.hasValue("node.roles")) {
return settings.getAsList("node.roles").contains(role.roleName());
} else if (role.legacySetting() != null && settings.hasValue(role.legacySetting().getKey())) {
return role.legacySetting().get(settings);
} else {
return role.isEnabledByDefault(settings);
}
Expand Down Expand Up @@ -212,32 +209,7 @@ public static DiscoveryNode createLocal(Settings settings, TransportAddress publ

/** extract node roles from the given settings */
public static Set<DiscoveryNodeRole> getRolesFromSettings(final Settings 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 {
return roleMap.values()
.stream()
.filter(s -> s.legacySetting() != null && s.legacySetting().get(settings))
.collect(Collectors.toUnmodifiableSet());
}
}

private static void validateLegacySettings(final Settings settings, final Map<String, DiscoveryNodeRole> roleMap) {
for (final DiscoveryNodeRole role : roleMap.values()) {
if (role.legacySetting() != null && role.legacySetting().exists(settings)) {
final String message = String.format(
Locale.ROOT,
"can not explicitly configure node roles and use legacy role setting [%s]=[%s]",
role.legacySetting().getKey(),
role.legacySetting().get(settings)
);
throw new IllegalArgumentException(message);
}
}
return Set.copyOf(NODE_ROLES_SETTING.get(settings));
}

/**
Expand Down Expand Up @@ -472,7 +444,6 @@ public static Collection<DiscoveryNodeRole> getPossibleRoles() {
}

public static void setAdditionalRoles(final Set<DiscoveryNodeRole> additionalRoles) {
assert additionalRoles.stream().allMatch(r -> r.legacySetting() == null || r.legacySetting().isDeprecated()) : additionalRoles;
final Map<String, DiscoveryNodeRole> roleNameToPossibleRoles =
rolesToMap(Stream.concat(DiscoveryNodeRole.BUILT_IN_ROLES.stream(), additionalRoles.stream()));
// collect the abbreviation names into a map to ensure that there are not any duplicate abbreviations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package org.elasticsearch.cluster.node;

import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;

Expand All @@ -20,7 +18,7 @@
/**
* Represents a node role.
*/
public abstract class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole> {
public class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a followup, but I wonder if we could make this final now. Seems like the only need for override is the enabled by default predicate, but this could be a lambda passed to the second constructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I will take a close look at opportunities for things like this when I get around to removing the plugin extension point for node roles.


private final String roleName;

Expand Down Expand Up @@ -59,7 +57,7 @@ public final boolean canContainData() {
private final boolean isKnownRole;

public boolean isEnabledByDefault(final Settings settings) {
return legacySetting() != null && legacySetting().get(settings);
return true;
}

protected DiscoveryNodeRole(final String roleName, final String roleNameAbbreviation) {
Expand All @@ -82,8 +80,6 @@ private DiscoveryNodeRole(
this.canContainData = canContainData;
}

public abstract Setting<Boolean> legacySetting();

@Override
public final boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -118,15 +114,7 @@ public final String toString() {
/**
* Represents the role for a data node.
*/
public static final DiscoveryNodeRole DATA_ROLE = new DiscoveryNodeRole("data", "d", true) {

@Override
public Setting<Boolean> legacySetting() {
// copy the setting here so we can mark it private in org.elasticsearch.node.Node
return Setting.boolSetting("node.data", true, Property.Deprecated, Property.NodeScope);
}

};
public static final DiscoveryNodeRole DATA_ROLE = new DiscoveryNodeRole("data", "d", true);

public static DiscoveryNodeRole DATA_CONTENT_NODE_ROLE = new DiscoveryNodeRole("data_content", "s", true) {

Expand All @@ -135,19 +123,6 @@ public boolean isEnabledByDefault(final Settings settings) {
return DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE);
}

@Override
public Setting<Boolean> legacySetting() {
// we do not register these settings, they're not intended to be used externally, only for proper defaults
return Setting.boolSetting(
"node.data_content",
settings ->
// Don't use DiscoveryNode#isDataNode(Settings) here, as it is called before all plugins are initialized
Boolean.toString(DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE)),
Property.Deprecated,
Property.NodeScope
);
}

};

public static DiscoveryNodeRole DATA_HOT_NODE_ROLE = new DiscoveryNodeRole("data_hot", "h", true) {
Expand All @@ -157,63 +132,24 @@ public boolean isEnabledByDefault(final Settings settings) {
return DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE);
}

@Override
public Setting<Boolean> legacySetting() {
// we do not register these settings, they're not intended to be used externally, only for proper defaults
return Setting.boolSetting(
"node.data_hot",
settings ->
// Don't use DiscoveryNode#isDataNode(Settings) here, as it is called before all plugins are initialized
Boolean.toString(DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE)),
Property.Deprecated,
Property.NodeScope
);
}

};


public static DiscoveryNodeRole DATA_WARM_NODE_ROLE = new DiscoveryNodeRole("data_warm", "w", true) {

@Override
public boolean isEnabledByDefault(final Settings settings) {
return DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE);
}

@Override
public Setting<Boolean> legacySetting() {
// we do not register these settings, they're not intended to be used externally, only for proper defaults
return Setting.boolSetting(
"node.data_warm",
settings ->
// Don't use DiscoveryNode#isDataNode(Settings) here, as it is called before all plugins are initialized
Boolean.toString(DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE)),
Property.Deprecated,
Property.NodeScope
);
}

};

public static DiscoveryNodeRole DATA_COLD_NODE_ROLE = new DiscoveryNodeRole("data_cold", "c", true) {

@Override
public boolean isEnabledByDefault(final Settings settings) {
return DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE);
}

@Override
public Setting<Boolean> legacySetting() {
// we do not register these settings, they're not intended to be used externally, only for proper defaults
return Setting.boolSetting(
"node.data_cold",
settings ->
// Don't use DiscoveryNode#isDataNode(Settings) here, as it is called before all plugins are initialized
Boolean.toString(DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE)),
Property.Deprecated,
Property.NodeScope
);
}

};

public static DiscoveryNodeRole DATA_FROZEN_NODE_ROLE = new DiscoveryNodeRole("data_frozen", "f", true) {
Expand All @@ -223,57 +159,19 @@ public boolean isEnabledByDefault(final Settings settings) {
return DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE);
}

@Override
public Setting<Boolean> legacySetting() {
// we do not register these settings, they're not intended to be used externally, only for proper defaults
return Setting.boolSetting(
"node.data_frozen",
settings ->
// Don't use DiscoveryNode#isDataNode(Settings) here, as it is called before all plugins are initialized
Boolean.toString(DiscoveryNode.hasRole(settings, DiscoveryNodeRole.DATA_ROLE)),
Property.Deprecated,
Property.NodeScope
);
}

};

/**
* Represents the role for an ingest node.
*/
public static final DiscoveryNodeRole INGEST_ROLE = new DiscoveryNodeRole("ingest", "i") {

@Override
public Setting<Boolean> legacySetting() {
// copy the setting here so we can mark it private in org.elasticsearch.node.Node
return Setting.boolSetting("node.ingest", true, Property.Deprecated, Property.NodeScope);
}

};
public static final DiscoveryNodeRole INGEST_ROLE = new DiscoveryNodeRole("ingest", "i");

/**
* Represents the role for a master-eligible node.
*/
public static final DiscoveryNodeRole MASTER_ROLE = new DiscoveryNodeRole("master", "m") {

@Override
public Setting<Boolean> legacySetting() {
// copy the setting here so we can mark it private in org.elasticsearch.node.Node
return Setting.boolSetting("node.master", true, Property.Deprecated, Property.NodeScope);
}

};

public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r") {

@Override
public Setting<Boolean> legacySetting() {
// copy the setting here so we can mark it private in org.elasticsearch.node.Node
return Setting.boolSetting("node.remote_cluster_client", true, Property.Deprecated, Property.NodeScope);
}

};
public static final DiscoveryNodeRole MASTER_ROLE = new DiscoveryNodeRole("master", "m");

public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r");
/**
* The built-in node roles.
*/
Expand Down Expand Up @@ -307,13 +205,6 @@ static class UnknownRole extends DiscoveryNodeRole {
super(false, roleName, roleNameAbbreviation, canContainData);
}

@Override
public Setting<Boolean> legacySetting() {
// since this setting is not registered, it will always return false when testing if the local node has the role
assert false;
return Setting.boolSetting("node. " + roleName(), false, Setting.Property.NodeScope);
}

}

}
Loading