[core] Java worker should respect the user provided node_ip_address (#13732)

This commit is contained in:
Xianyang Liu
2021-02-08 11:59:06 +08:00
committed by GitHub
parent 7231b6b91c
commit 918ad84f08
2 changed files with 53 additions and 1 deletions
@@ -0,0 +1,46 @@
package io.ray.test;
import io.ray.api.Ray;
import org.apache.commons.lang3.SystemUtils;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = {"cluster"})
public class NodeIpTest extends BaseTest {
private static final String NODE_IP = "127.0.0.2";
@BeforeClass
public void setUp() {
if (SystemUtils.IS_OS_MAC) {
throw new SkipException("Skip NodeIpTest on Mac OS");
}
System.setProperty("ray.head-args.0", "--node-ip-address=127.0.0.2");
System.setProperty("ray.node-ip", "127.0.0.2");
}
@AfterClass
public void tearDown() {
if (!SystemUtils.IS_OS_MAC) {
System.clearProperty("ray.head-args.0");
System.clearProperty("ray.node-ip");
}
}
static String getNodeIp() {
return TestUtils.getRuntime().getRayConfig().nodeIp;
}
public void testNodeIp() {
// this is on the driver node, and it should be equal with ray.node-ip
String nodeIP = TestUtils.getRuntime().getRayConfig().nodeIp;
Assert.assertEquals(nodeIP, NODE_IP);
// this is on the worker node, and it should be equal with node-ip-address
nodeIP = Ray.task(NodeIpTest::getNodeIp).remote().get();
Assert.assertEquals(nodeIP, NODE_IP);
}
}
+7 -1
View File
@@ -1370,6 +1370,7 @@ def start_raylet(redis_address,
raylet_name,
redis_password,
session_dir,
node_ip_address,
)
else:
java_worker_command = []
@@ -1508,7 +1509,8 @@ def get_ray_jars_dir():
def build_java_worker_command(java_worker_options, redis_address,
node_manager_port, plasma_store_name,
raylet_name, redis_password, session_dir):
raylet_name, redis_password, session_dir,
node_ip_address):
"""This method assembles the command used to start a Java worker.
Args:
@@ -1519,6 +1521,7 @@ def build_java_worker_command(java_worker_options, redis_address,
raylet_name (str): The name of the raylet socket to create.
redis_password (str): The password of connect to redis.
session_dir (str): The path of this session.
node_ip_address (str): The ip address for this node.
Returns:
The command string for starting Java worker.
"""
@@ -1536,6 +1539,9 @@ def build_java_worker_command(java_worker_options, redis_address,
if redis_password is not None:
pairs.append(("ray.redis.password", redis_password))
if node_ip_address is not None:
pairs.append(("ray.node-ip", node_ip_address))
pairs.append(("ray.home", RAY_HOME))
pairs.append(("ray.logging.dir", os.path.join(session_dir, "logs")))
pairs.append(("ray.session-dir", session_dir))