From 8c08e3cfd727fa243e7de93c5676927f01fabe1e Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Mon, 8 Apr 2024 10:21:38 -0700 Subject: [PATCH 1/2] agent out of the setting only_run_on_ml_node Signed-off-by: Jing Zhang --- .../opensearch/ml/cluster/DiscoveryNodeHelper.java | 2 +- .../opensearch/ml/settings/MLCommonsSettings.java | 2 +- .../ml/cluster/DiscoveryNodeHelperTests.java | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java b/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java index 5b06236d54..694b08ede8 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java @@ -73,7 +73,7 @@ public DiscoveryNode[] getEligibleNodes(FunctionName functionName) { if (excludedNodeNames != null && excludedNodeNames.contains(node.getName())) { continue; } - if (functionName == FunctionName.REMOTE) {// remote model + if (functionName == FunctionName.REMOTE || functionName == FunctionName.AGENT) {// remote model getEligibleNode(remoteModelEligibleNodeRoles, eligibleNodes, node); } else { // local model if (onlyRunOnMLNode) { diff --git a/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java b/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java index 6cc4029e78..ba0c13e614 100644 --- a/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java +++ b/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java @@ -37,7 +37,7 @@ private MLCommonsSettings() {} public static final Setting ML_COMMONS_MAX_ML_TASK_PER_NODE = Setting .intSetting("plugins.ml_commons.max_ml_task_per_node", 10, 0, 10000, Setting.Property.NodeScope, Setting.Property.Dynamic); public static final Setting ML_COMMONS_ONLY_RUN_ON_ML_NODE = Setting - .boolSetting("plugins.ml_commons.only_run_on_ml_node", false, Setting.Property.NodeScope, Setting.Property.Dynamic); + .boolSetting("plugins.ml_commons.only_run_on_ml_node", true, Setting.Property.NodeScope, Setting.Property.Dynamic); public static final Setting ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL = Setting .boolSetting("plugins.ml_commons.enable_inhouse_python_model", false, Setting.Property.NodeScope, Setting.Property.Dynamic); diff --git a/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java b/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java index 84df4ccb3e..7299090ccb 100644 --- a/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java +++ b/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java @@ -182,6 +182,19 @@ public void testGetEligibleNodes_MLNode_RemoteModel() { assertFalse(nodeIds.contains(warmDataNode1.getId())); } + public void testGetEligibleNodes_MLNode_Agent() { + DiscoveryNode[] eligibleNodes = discoveryNodeHelper.getEligibleNodes(FunctionName.AGENT); + assertEquals(5, eligibleNodes.length); + Set nodeIds = new HashSet<>(); + nodeIds.addAll(Arrays.asList(eligibleNodes).stream().map(n -> n.getId()).collect(Collectors.toList())); + assertTrue(nodeIds.contains(mlNode1.getId())); + assertTrue(nodeIds.contains(mlNode2.getId())); + assertTrue(nodeIds.contains(dataNode1.getId())); + assertTrue(nodeIds.contains(dataNode2.getId())); + assertTrue(nodeIds.contains(allRoleNode.getId())); + assertFalse(nodeIds.contains(warmDataNode1.getId())); + } + public void testGetEligibleNodes_MLNode_LocalModel() { DiscoveryNode[] eligibleNodes = discoveryNodeHelper.getEligibleNodes(FunctionName.TEXT_EMBEDDING); assertEquals(3, eligibleNodes.length); From 66905bdf218857c776e4262b906e8143fb640771 Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Mon, 8 Apr 2024 11:54:41 -0700 Subject: [PATCH 2/2] address comments Signed-off-by: Jing Zhang --- .../java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java b/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java index 694b08ede8..16556bc12b 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java @@ -73,7 +73,7 @@ public DiscoveryNode[] getEligibleNodes(FunctionName functionName) { if (excludedNodeNames != null && excludedNodeNames.contains(node.getName())) { continue; } - if (functionName == FunctionName.REMOTE || functionName == FunctionName.AGENT) {// remote model + if (functionName == FunctionName.REMOTE || functionName == FunctionName.AGENT) {// non-local model (remote model, agent) getEligibleNode(remoteModelEligibleNodeRoles, eligibleNodes, node); } else { // local model if (onlyRunOnMLNode) {