From d2023b111b1437712beb08893dd0a37b255726f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Fr=C3=BDda?= Date: Wed, 18 Sep 2024 13:47:47 +0200 Subject: [PATCH] GH-16360: Fix R package for Windows (#16369) * Fix R package for Windows * Fix pyunit_cluster test --- h2o-core/src/main/java/water/api/CloudHandler.java | 2 +- .../src/main/java/water/api/schemas3/CloudV3.java | 3 +++ h2o-py/tests/testdir_misc/pyunit_cluster.py | 4 ++-- h2o-r/h2o-package/R/communication.R | 5 +++++ h2o-r/h2o-package/R/connection.R | 11 ----------- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/h2o-core/src/main/java/water/api/CloudHandler.java b/h2o-core/src/main/java/water/api/CloudHandler.java index 684dc9202d77..4058c9931d02 100644 --- a/h2o-core/src/main/java/water/api/CloudHandler.java +++ b/h2o-core/src/main/java/water/api/CloudHandler.java @@ -40,7 +40,7 @@ public CloudV3 status(int version, CloudV3 cloud) { cloud.consensus = Paxos._commonKnowledge; cloud.locked = Paxos._cloudLocked; cloud.internal_security_enabled = H2OSecurityManager.instance().securityEnabled; - + cloud.web_ip = H2O.ARGS.web_ip; // set leader H2ONode leader = H2O.CLOUD.leaderOrNull(); // leader might be null in client mode if clouding didn't finish yet diff --git a/h2o-core/src/main/java/water/api/schemas3/CloudV3.java b/h2o-core/src/main/java/water/api/schemas3/CloudV3.java index 7bdccce6b43c..99b2956e0a5c 100644 --- a/h2o-core/src/main/java/water/api/schemas3/CloudV3.java +++ b/h2o-core/src/main/java/water/api/schemas3/CloudV3.java @@ -110,6 +110,9 @@ public CloudV3() {} @API(help="leader_idx", direction=API.Direction.OUTPUT) public int leader_idx = -1; + @API(help="web_ip", direction=API.Direction.OUTPUT) + public String web_ip=null; + // Output fields one-per-JVM public static class NodeV3 extends SchemaV3 { public NodeV3() {} diff --git a/h2o-py/tests/testdir_misc/pyunit_cluster.py b/h2o-py/tests/testdir_misc/pyunit_cluster.py index 2424170ef1d6..9c367484a27f 100644 --- a/h2o-py/tests/testdir_misc/pyunit_cluster.py +++ b/h2o-py/tests/testdir_misc/pyunit_cluster.py @@ -11,9 +11,9 @@ def test_cluster_status(): def test_cluster_properties(): cl = h2o.cluster() - assert len(cl._schema_attrs_) == 24 + assert len(cl._schema_attrs_) == 25 for k in cl._schema_attrs_.keys(): - assert getattr(cl, k) is not None + assert getattr(cl, k) is not None or k == "web_ip" def test_exception_on_unknown_cluster_property(): diff --git a/h2o-r/h2o-package/R/communication.R b/h2o-r/h2o-package/R/communication.R index ad6263e0f5d4..3ce957a3448f 100755 --- a/h2o-r/h2o-package/R/communication.R +++ b/h2o-r/h2o-package/R/communication.R @@ -968,6 +968,11 @@ h2o.clusterInfo <- function() { if (res$build_too_old) { warning(sprintf("\nYour H2O cluster version is (%s) old. There may be a newer version available.\nPlease download and install the latest version from: https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html", res$build_age)) } + + if (is.null(res$web_ip)){ + warning("SECURITY_WARNING: web_ip is not specified. H2O Rest API is listening on all available interfaces.") + } + } .h2o.translateJobType <- function(type) { diff --git a/h2o-r/h2o-package/R/connection.R b/h2o-r/h2o-package/R/connection.R index 8971ec9d335a..f449777653d9 100755 --- a/h2o-r/h2o-package/R/connection.R +++ b/h2o-r/h2o-package/R/connection.R @@ -237,17 +237,6 @@ h2o.init <- function(ip = "localhost", port = 54321, name = NA_character_, start stop("H2O failed to start, stopping execution.") } - - securityWarnings <- "" - if (file.info(stdout)$size > 0) { - securityWarnings <- grep("SECURITY_WARNING", readLines(stdout), value=TRUE) - } - if (length(securityWarnings) > 0) { - msg = paste( - "Server process startup raise a security warning:", - paste(securityWarnings, collapse = "\n"), sep = "\n") - warning(msg) - } } else stop("Can only start H2O launcher if IP address is localhost.") }