Skip to content

Commit 202b4fb

Browse files
authored
[Transform] Remove node.attr.transform.remote_connect and use new remote cluster client node role (#54217)
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 #54179
1 parent 995bed2 commit 202b4fb

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.elasticsearch.env.NodeEnvironment;
3333
import org.elasticsearch.indices.SystemIndexDescriptor;
3434
import org.elasticsearch.license.XPackLicenseState;
35-
import org.elasticsearch.node.Node;
3635
import org.elasticsearch.persistent.PersistentTasksExecutor;
3736
import org.elasticsearch.plugins.PersistentTaskPlugin;
3837
import org.elasticsearch.plugins.Plugin;
@@ -148,7 +147,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa
148147
* These attributes should never be set directly, use the node setting counter parts instead.
149148
*/
150149
public static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node";
151-
public static final String TRANSFORM_REMOTE_ENABLED_NODE_ATTR = "transform.remote_connect";
152150

153151
/**
154152
* Setting whether transform (the coordinator task) can run on this node and REST API's are available,
@@ -355,9 +353,8 @@ public List<Setting<?>> getSettings() {
355353
@Override
356354
public Settings additionalSettings() {
357355
String transformEnabledNodeAttribute = "node.attr." + TRANSFORM_ENABLED_NODE_ATTR;
358-
String transformRemoteEnabledNodeAttribute = "node.attr." + TRANSFORM_REMOTE_ENABLED_NODE_ATTR;
359356

360-
if (settings.get(transformEnabledNodeAttribute) != null || settings.get(transformRemoteEnabledNodeAttribute) != null) {
357+
if (settings.get(transformEnabledNodeAttribute) != null) {
361358
throw new IllegalArgumentException(
362359
"Directly setting transform node attributes is not permitted, please use the documented node settings instead"
363360
);
@@ -370,7 +367,6 @@ public Settings additionalSettings() {
370367
Settings.Builder additionalSettings = Settings.builder();
371368

372369
additionalSettings.put(transformEnabledNodeAttribute, TRANSFORM_ENABLED_NODE.get(settings));
373-
additionalSettings.put(transformRemoteEnabledNodeAttribute, Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings));
374370

375371
return additionalSettings.build();
376372
}

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static boolean nodeCanRunThisTransform(DiscoveryNode node, TransformTaskP
146146
}
147147

148148
// does the transform require a remote and remote is enabled?
149-
if (params.requiresRemote() && Boolean.parseBoolean(nodeAttributes.get(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR)) == false) {
149+
if (params.requiresRemote() && node.isRemoteClusterClient() == false) {
150150
if (explain != null) {
151151
explain.put(node.getId(), "transform requires a remote connection but remote is disabled");
152152
}

x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@ public void testNodeAttributes() {
1919
Settings.Builder builder = Settings.builder();
2020
boolean transformEnabled = randomBoolean();
2121
boolean transformPluginEnabled = randomBoolean();
22-
boolean remoteClusterClient = randomBoolean();
2322

2423
// randomly use explicit or default setting
2524
if ((transformEnabled && randomBoolean()) == false) {
2625
builder.put("node.transform", transformEnabled);
2726
}
2827

29-
// randomly use explicit or default setting
30-
if ((remoteClusterClient && randomBoolean()) == false) {
31-
builder.put("node.remote_cluster_client", remoteClusterClient);
32-
}
33-
3428
if (transformPluginEnabled == false) {
3529
builder.put("xpack.transform.enabled", transformPluginEnabled);
3630
}
@@ -42,23 +36,14 @@ public void testNodeAttributes() {
4236
transformPluginEnabled && transformEnabled,
4337
Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.node"))
4438
);
45-
assertEquals(
46-
transformPluginEnabled && remoteClusterClient,
47-
Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.remote_connect"))
48-
);
4939
}
5040

5141
public void testNodeAttributesDirectlyGiven() {
5242
Settings.Builder builder = Settings.builder();
53-
54-
if (randomBoolean()) {
55-
builder.put("node.attr.transform.node", randomBoolean());
56-
} else {
57-
builder.put("node.attr.transform.remote_connect", randomBoolean());
58-
}
43+
builder.put("node.attr.transform.node", randomBoolean());
5944

6045
Transform transform = createTransform(builder.build());
61-
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> transform.additionalSettings());
46+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, transform::additionalSettings);
6247
assertThat(
6348
e.getMessage(),
6449
equalTo("Directly setting transform node attributes is not permitted, please use the documented node settings instead")

x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/TransformPersistentTasksExecutorTests.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,14 @@ private DiscoveryNodes.Builder buildNodes(
243243
boolean dedicatedTransformNode,
244244
boolean pastDataNode,
245245
boolean transformRemoteNodes,
246-
boolean transformLocanOnlyNodes,
246+
boolean transformLocalOnlyNodes,
247247
boolean currentDataNode
248248
) {
249249

250250
Map<String, String> transformNodeAttributes = new HashMap<>();
251251
transformNodeAttributes.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true");
252-
transformNodeAttributes.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "true");
253252
Map<String, String> transformNodeAttributesDisabled = new HashMap<>();
254253
transformNodeAttributesDisabled.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "false");
255-
transformNodeAttributesDisabled.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "true");
256-
Map<String, String> transformNodeAttributesNoRemote = new HashMap<>();
257-
transformNodeAttributesNoRemote.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true");
258-
transformNodeAttributesNoRemote.put(Transform.TRANSFORM_REMOTE_ENABLED_NODE_ATTR, "false");
259254

260255
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder();
261256

@@ -265,7 +260,7 @@ private DiscoveryNodes.Builder buildNodes(
265260
"dedicated-transform-node",
266261
buildNewFakeTransportAddress(),
267262
transformNodeAttributes,
268-
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
263+
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
269264
Version.CURRENT
270265
)
271266
);
@@ -277,7 +272,9 @@ private DiscoveryNodes.Builder buildNodes(
277272
"past-data-node-1",
278273
buildNewFakeTransportAddress(),
279274
transformNodeAttributes,
280-
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)),
275+
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE,
276+
DiscoveryNodeRole.MASTER_ROLE,
277+
DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
281278
Version.V_7_7_0
282279
)
283280
);
@@ -289,7 +286,7 @@ private DiscoveryNodes.Builder buildNodes(
289286
"current-data-node-with-2-tasks",
290287
buildNewFakeTransportAddress(),
291288
transformNodeAttributes,
292-
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE)),
289+
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
293290
Version.CURRENT
294291
)
295292
)
@@ -298,18 +295,18 @@ private DiscoveryNodes.Builder buildNodes(
298295
"current-data-node-with-1-tasks",
299296
buildNewFakeTransportAddress(),
300297
transformNodeAttributes,
301-
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)),
298+
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
302299
Version.CURRENT
303300
)
304301
);
305302
}
306303

307-
if (transformLocanOnlyNodes) {
304+
if (transformLocalOnlyNodes) {
308305
nodes.add(
309306
new DiscoveryNode(
310307
"current-data-node-with-0-tasks-transform-remote-disabled",
311308
buildNewFakeTransportAddress(),
312-
transformNodeAttributesNoRemote,
309+
transformNodeAttributes,
313310
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)),
314311
Version.CURRENT
315312
)
@@ -322,7 +319,7 @@ private DiscoveryNodes.Builder buildNodes(
322319
"current-data-node-with-transform-disabled",
323320
buildNewFakeTransportAddress(),
324321
transformNodeAttributesDisabled,
325-
Set.of(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE),
322+
Set.of(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE),
326323
Version.CURRENT
327324
)
328325
);

0 commit comments

Comments
 (0)