From ac5ea2c13d239ab952db74c33dcb69636e1b9ab8 Mon Sep 17 00:00:00 2001 From: Kai Yang Date: Sat, 19 Dec 2020 10:22:12 +0800 Subject: [PATCH] [Java] Fix output parsing in RunManager (#12968) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix output parsing in RunManager * change log level Co-authored-by: 灵洵 --- .../main/java/io/ray/runtime/runner/RunManager.java | 8 ++++++-- python/ray/_private/services.py | 12 +++++------- src/ray/gcs/gcs_client/service_based_gcs_client.cc | 12 ++++++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/java/runtime/src/main/java/io/ray/runtime/runner/RunManager.java b/java/runtime/src/main/java/io/ray/runtime/runner/RunManager.java index b6ed41f7f..4bd49deb4 100644 --- a/java/runtime/src/main/java/io/ray/runtime/runner/RunManager.java +++ b/java/runtime/src/main/java/io/ray/runtime/runner/RunManager.java @@ -75,14 +75,18 @@ public class RunManager { // address info of the local node. String script = String.format("import ray;" + " print(ray._private.services.get_address_info_from_redis(" - + "'%s', '%s', redis_password='%s', no_warning=True))", + + "'%s', '%s', redis_password='%s'))", rayConfig.getRedisAddress(), rayConfig.nodeIp, rayConfig.redisPassword); List command = Arrays.asList("python", "-c", script); String output = null; try { output = runCommand(command); - JsonObject addressInfo = new JsonParser().parse(output).getAsJsonObject(); + // NOTE(kfstorm): We only parse the last line here in case there are some warning + // messages appear at the beginning. + String[] lines = output.split(System.lineSeparator()); + String lastLine = lines[lines.length - 1]; + JsonObject addressInfo = new JsonParser().parse(lastLine).getAsJsonObject(); rayConfig.rayletSocketName = addressInfo.get("raylet_socket_name").getAsString(); rayConfig.objectStoreSocketName = addressInfo.get("object_store_address").getAsString(); rayConfig.nodeManagerPort = addressInfo.get("node_manager_port").getAsInt(); diff --git a/python/ray/_private/services.py b/python/ray/_private/services.py index c3512ab92..6d8bbb97c 100644 --- a/python/ray/_private/services.py +++ b/python/ray/_private/services.py @@ -279,8 +279,7 @@ def get_address_info_from_redis_helper(redis_address, def get_address_info_from_redis(redis_address, node_ip_address, num_retries=5, - redis_password=None, - no_warning=False): + redis_password=None): counter = 0 while True: try: @@ -291,11 +290,10 @@ def get_address_info_from_redis(redis_address, raise # Some of the information may not be in Redis yet, so wait a little # bit. - if not no_warning: - logger.warning( - "Some processes that the driver needs to connect to have " - "not registered with Redis, so retrying. Have you run " - "'ray start' on this node?") + logger.warning( + "Some processes that the driver needs to connect to have " + "not registered with Redis, so retrying. Have you run " + "'ray start' on this node?") time.sleep(1) counter += 1 diff --git a/src/ray/gcs/gcs_client/service_based_gcs_client.cc b/src/ray/gcs/gcs_client/service_based_gcs_client.cc index 884612106..f643496b8 100644 --- a/src/ray/gcs/gcs_client/service_based_gcs_client.cc +++ b/src/ray/gcs/gcs_client/service_based_gcs_client.cc @@ -209,11 +209,15 @@ void ServiceBasedGcsClient::ReconnectGcsServer() { return; } - RAY_LOG(INFO) << "Attemptting to reconnect to GCS server: " << address.first << ":" - << address.second; + RAY_LOG(DEBUG) << "Attemptting to reconnect to GCS server: " << address.first << ":" + << address.second; if (Ping(address.first, address.second, 100)) { - RAY_LOG(INFO) << "Reconnected to GCS server: " << address.first << ":" - << address.second; + // If `last_reconnect_address_` port is -1, it means that this is the first + // connection and no log will be printed. + if (last_reconnect_address_.second != -1) { + RAY_LOG(INFO) << "Reconnected to GCS server: " << address.first << ":" + << address.second; + } break; } }