[Transform] Remove node.attr.transform.remote_connect and use new remote cluster client node role (#54217) (#54224)

With the addition of a formal role for nodes indicating remote cluster connection, the transform specific attribute `node.attr.transform.remote_connect` is no longer necessary.

closes https://github.com/elastic/elasticsearch/issues/54179
This commit is contained in:
Benjamin Trent 2020-03-25 16:29:02 -04:00 committed by GitHub
parent 8f40f1435a
commit 6d68cf809c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 37 deletions

View File

@ -34,7 +34,6 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.node.Node;
import org.elasticsearch.persistent.PersistentTasksExecutor; import org.elasticsearch.persistent.PersistentTasksExecutor;
import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.PersistentTaskPlugin;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
@ -150,7 +149,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa
* These attributes should never be set directly, use the node setting counter parts instead. * These attributes should never be set directly, use the node setting counter parts instead.
*/ */
public static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node"; public static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node";
public static final String TRANSFORM_REMOTE_ENABLED_NODE_ATTR = "transform.remote_connect";
/** /**
* Setting whether transform (the coordinator task) can run on this node and REST API's are available, * Setting whether transform (the coordinator task) can run on this node and REST API's are available,
@ -367,9 +365,8 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa
@Override @Override
public Settings additionalSettings() { public Settings additionalSettings() {
String transformEnabledNodeAttribute = "node.attr." + TRANSFORM_ENABLED_NODE_ATTR; String transformEnabledNodeAttribute = "node.attr." + TRANSFORM_ENABLED_NODE_ATTR;
String transformRemoteEnabledNodeAttribute = "node.attr." + TRANSFORM_REMOTE_ENABLED_NODE_ATTR;
if (settings.get(transformEnabledNodeAttribute) != null || settings.get(transformRemoteEnabledNodeAttribute) != null) { if (settings.get(transformEnabledNodeAttribute) != null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Directly setting transform node attributes is not permitted, please use the documented node settings instead" "Directly setting transform node attributes is not permitted, please use the documented node settings instead"
); );
@ -382,7 +379,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa
Settings.Builder additionalSettings = Settings.builder(); Settings.Builder additionalSettings = Settings.builder();
additionalSettings.put(transformEnabledNodeAttribute, TRANSFORM_ENABLED_NODE.get(settings)); additionalSettings.put(transformEnabledNodeAttribute, TRANSFORM_ENABLED_NODE.get(settings));
additionalSettings.put(transformRemoteEnabledNodeAttribute, Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings));
return additionalSettings.build(); return additionalSettings.build();
} }

View File

@ -186,7 +186,7 @@ public class TransformPersistentTasksExecutor extends PersistentTasksExecutor<Tr
} }
// does the transform require a remote and remote is enabled? // does the transform require a remote and remote is enabled?
if (params.requiresRemote() && Boolean.parseBoolean(nodeAttributes.get(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR)) == false) { if (params.requiresRemote() && node.isRemoteClusterClient() == false) {
if (explain != null) { if (explain != null) {
explain.put(node.getId(), "transform requires a remote connection but remote is disabled"); explain.put(node.getId(), "transform requires a remote connection but remote is disabled");
} }

View File

@ -19,18 +19,12 @@ public class TransformTests extends ESTestCase {
Settings.Builder builder = Settings.builder(); Settings.Builder builder = Settings.builder();
boolean transformEnabled = randomBoolean(); boolean transformEnabled = randomBoolean();
boolean transformPluginEnabled = randomBoolean(); boolean transformPluginEnabled = randomBoolean();
boolean remoteClusterClient = randomBoolean();
// randomly use explicit or default setting // randomly use explicit or default setting
if ((transformEnabled && randomBoolean()) == false) { if ((transformEnabled && randomBoolean()) == false) {
builder.put("node.transform", transformEnabled); builder.put("node.transform", transformEnabled);
} }
// randomly use explicit or default setting
if ((remoteClusterClient && randomBoolean()) == false) {
builder.put("node.remote_cluster_client", remoteClusterClient);
}
if (transformPluginEnabled == false) { if (transformPluginEnabled == false) {
builder.put("xpack.transform.enabled", transformPluginEnabled); builder.put("xpack.transform.enabled", transformPluginEnabled);
} }
@ -42,23 +36,14 @@ public class TransformTests extends ESTestCase {
transformPluginEnabled && transformEnabled, transformPluginEnabled && transformEnabled,
Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.node")) Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.node"))
); );
assertEquals(
transformPluginEnabled && remoteClusterClient,
Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.remote_connect"))
);
} }
public void testNodeAttributesDirectlyGiven() { public void testNodeAttributesDirectlyGiven() {
Settings.Builder builder = Settings.builder(); Settings.Builder builder = Settings.builder();
builder.put("node.attr.transform.node", randomBoolean());
if (randomBoolean()) {
builder.put("node.attr.transform.node", randomBoolean());
} else {
builder.put("node.attr.transform.remote_connect", randomBoolean());
}
Transform transform = createTransform(builder.build()); Transform transform = createTransform(builder.build());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> transform.additionalSettings()); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, transform::additionalSettings);
assertThat( assertThat(
e.getMessage(), e.getMessage(),
equalTo("Directly setting transform node attributes is not permitted, please use the documented node settings instead") equalTo("Directly setting transform node attributes is not permitted, please use the documented node settings instead")

View File

@ -170,7 +170,6 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
public void testDoNotSelectOldNodes() { public void testDoNotSelectOldNodes() {
Map<String, String> transformNodeAttributes = new HashMap<>(); Map<String, String> transformNodeAttributes = new HashMap<>();
transformNodeAttributes.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true"); transformNodeAttributes.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true");
transformNodeAttributes.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "true");
MetaData.Builder metaData = MetaData.builder(); MetaData.Builder metaData = MetaData.builder();
RoutingTable.Builder routingTable = RoutingTable.builder(); RoutingTable.Builder routingTable = RoutingTable.builder();
addIndices(metaData, routingTable); addIndices(metaData, routingTable);
@ -201,7 +200,11 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
"current-data-node-with-1-task", "current-data-node-with-1-task",
buildNewFakeTransportAddress(), buildNewFakeTransportAddress(),
transformNodeAttributes, transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)), new HashSet<>(Arrays.asList(
DiscoveryNodeRole.DATA_ROLE,
DiscoveryNodeRole.MASTER_ROLE,
DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE
)),
Version.CURRENT Version.CURRENT
) )
) )
@ -358,18 +361,13 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
boolean dedicatedTransformNode, boolean dedicatedTransformNode,
boolean pastDataNode, boolean pastDataNode,
boolean transformRemoteNodes, boolean transformRemoteNodes,
boolean transformLocanOnlyNodes, boolean transformLocalOnlyNodes,
boolean currentDataNode boolean currentDataNode
) { ) {
Map<String, String> transformNodeAttributes = new HashMap<>(); Map<String, String> transformNodeAttributes = new HashMap<>();
transformNodeAttributes.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true"); transformNodeAttributes.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true");
transformNodeAttributes.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "true");
Map<String, String> transformNodeAttributesDisabled = new HashMap<>(); Map<String, String> transformNodeAttributesDisabled = new HashMap<>();
transformNodeAttributesDisabled.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "false"); transformNodeAttributesDisabled.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "false");
transformNodeAttributesDisabled.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "true");
Map<String, String> transformNodeAttributesNoRemote = new HashMap<>();
transformNodeAttributesNoRemote.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true");
transformNodeAttributesNoRemote.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "false");
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(); DiscoveryNodes.Builder nodes = DiscoveryNodes.builder();
@ -379,7 +377,7 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
"dedicated-transform-node", "dedicated-transform-node",
buildNewFakeTransportAddress(), buildNewFakeTransportAddress(),
transformNodeAttributes, transformNodeAttributes,
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Version.CURRENT Version.CURRENT
) )
); );
@ -403,7 +401,7 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
"current-data-node-with-2-tasks", "current-data-node-with-2-tasks",
buildNewFakeTransportAddress(), buildNewFakeTransportAddress(),
transformNodeAttributes, transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE)), new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Version.CURRENT Version.CURRENT
) )
) )
@ -412,18 +410,18 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
"current-data-node-with-1-tasks", "current-data-node-with-1-tasks",
buildNewFakeTransportAddress(), buildNewFakeTransportAddress(),
transformNodeAttributes, transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)), new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Version.CURRENT Version.CURRENT
) )
); );
} }
if (transformLocanOnlyNodes) { if (transformLocalOnlyNodes) {
nodes.add( nodes.add(
new DiscoveryNode( new DiscoveryNode(
"current-data-node-with-0-tasks-transform-remote-disabled", "current-data-node-with-0-tasks-transform-remote-disabled",
buildNewFakeTransportAddress(), buildNewFakeTransportAddress(),
transformNodeAttributesNoRemote, transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)), new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)),
Version.CURRENT Version.CURRENT
) )
@ -436,7 +434,11 @@ public class TransformPersistentTasksExecutorTests extends ESTestCase {
"current-data-node-with-transform-disabled", "current-data-node-with-transform-disabled",
buildNewFakeTransportAddress(), buildNewFakeTransportAddress(),
transformNodeAttributesDisabled, transformNodeAttributesDisabled,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)), new HashSet<>(Arrays.asList(
DiscoveryNodeRole.DATA_ROLE,
DiscoveryNodeRole.MASTER_ROLE,
DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE
)),
Version.CURRENT Version.CURRENT
) )
); );