From 0c6bb745cd07dd2ff15f8394f739faa31c951137 Mon Sep 17 00:00:00 2001 From: fyrestone Date: Tue, 17 Nov 2020 04:02:20 +0800 Subject: [PATCH] Fix dashboard agent use incorrect ip (#12038) --- dashboard/agent.py | 13 ++++++++++--- python/ray/_private/services.py | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dashboard/agent.py b/dashboard/agent.py index 03e4e9eff..84404987a 100644 --- a/dashboard/agent.py +++ b/dashboard/agent.py @@ -38,6 +38,7 @@ aiogrpc.init_grpc_aio() class DashboardAgent(object): def __init__(self, + node_ip_address, redis_address, dashboard_agent_port, redis_password=None, @@ -49,6 +50,7 @@ class DashboardAgent(object): raylet_name=None): """Initialize the DashboardAgent object.""" # Public attributes are accessible for all agent modules. + self.ip = node_ip_address self.redis_address = dashboard_utils.address_tuple(redis_address) self.redis_password = redis_password self.temp_dir = temp_dir @@ -60,15 +62,14 @@ class DashboardAgent(object): self.raylet_name = raylet_name self.node_id = os.environ["RAY_NODE_ID"] assert self.node_id, "Empty node id (RAY_NODE_ID)." - self.ip = ray._private.services.get_node_ip_address() self.server = aiogrpc.server(options=(("grpc.so_reuseport", 0), )) self.grpc_port = self.server.add_insecure_port( f"[::]:{self.dashboard_agent_port}") logger.info("Dashboard agent grpc address: %s:%s", self.ip, self.grpc_port) self.aioredis_client = None - self.aiogrpc_raylet_channel = aiogrpc.insecure_channel("{}:{}".format( - self.ip, self.node_manager_port)) + self.aiogrpc_raylet_channel = aiogrpc.insecure_channel( + f"{self.ip}:{self.node_manager_port}") self.http_session = None def _load_modules(self): @@ -180,6 +181,11 @@ class DashboardAgent(object): if __name__ == "__main__": parser = argparse.ArgumentParser(description="Dashboard agent.") + parser.add_argument( + "--node-ip-address", + required=True, + type=str, + help="the IP address of this node.") parser.add_argument( "--redis-address", required=True, @@ -284,6 +290,7 @@ if __name__ == "__main__": handlers=logging_handlers) agent = DashboardAgent( + args.node_ip_address, args.redis_address, args.dashboard_agent_port, redis_password=args.redis_password, diff --git a/python/ray/_private/services.py b/python/ray/_private/services.py index 477b6cfad..386ac4efd 100644 --- a/python/ray/_private/services.py +++ b/python/ray/_private/services.py @@ -1402,6 +1402,7 @@ def start_raylet(redis_address, sys.executable, "-u", os.path.join(RAY_PATH, "new_dashboard/agent.py"), + f"--node-ip-address={node_ip_address}", f"--redis-address={redis_address}", f"--metrics-export-port={metrics_export_port}", f"--dashboard-agent-port={metrics_agent_port}",