[Java] Use localhost instead of public ip (#21462)

Use localhost ip address instead of public ip for avoid security popups on MacOS.
This also reverts This reverts commit e4542be0d1.
This commit is contained in:
Qing Wang 2022-01-11 02:58:22 +08:00 committed by GitHub
parent 71fae21e8e
commit 57ff13461c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View file

@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
/** Configurations of Ray runtime. See `ray.default.conf` for the meaning of each field. */
public class RayConfig {
@ -111,8 +112,15 @@ public class RayConfig {
if (config.hasPath("ray.node-ip")) {
nodeIp = config.getString("ray.node-ip");
} else {
nodeIp = NetworkUtil.getIpAddress(null);
if (SystemUtils.IS_OS_LINUX) {
nodeIp = NetworkUtil.getIpAddress(null);
} else {
/// We use a localhost on MacOS or Windows to avid security popups.
/// See the related issue https://github.com/ray-project/ray/issues/18730
nodeIp = NetworkUtil.localhostIp();
}
}
// Job id.
String jobId = config.getString("ray.job.id");
if (!jobId.isEmpty()) {

View file

@ -28,8 +28,6 @@ public class RunManager {
command.add("--head");
command.add("--redis-password");
command.add(rayConfig.redisPassword);
command.add("--node-ip-address");
command.add(rayConfig.nodeIp);
command.addAll(rayConfig.headArgs);
String numGpus = System.getProperty("num-gpus");

View file

@ -43,4 +43,8 @@ public class NetworkUtil {
return "127.0.0.1";
}
public static String localhostIp() {
return "127.0.0.1";
}
}