# Buggy code
def __init__(
    self,
    redis_address,
    dashboard_agent_port,
    redis_password=None,
    temp_dir=None,
    log_dir=None,
    metrics_export_port=None,
    node_manager_port=None,
    object_store_name=None,
    raylet_name=None,
):
    """Initialize the DashboardAgent object."""
    # Public attributes are accessible for all agent modules.
    self.redis_address = dashboard_utils.address_tuple(redis_address)
    self.redis_password = redis_password
    self.temp_dir = temp_dir
    self.log_dir = log_dir
    self.dashboard_agent_port = dashboard_agent_port
    self.metrics_export_port = metrics_export_port
    self.node_manager_port = node_manager_port
    self.object_store_name = object_store_name
    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.http_session = None


# Traceback (grpc.experimental.aio._call.AioRpcError)
2020-11-11 14:13:37,114	WARNING worker.py:1111 -- The agent on node *** failed with the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/ray/new_dashboard/agent.py", line 298, in <module>
loop.run_until_complete(agent.run())
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/usr/local/lib/python3.6/dist-packages/ray/new_dashboard/agent.py", line 172, in run
agent_ip_address=self.ip))
File "/usr/local/lib/python3.6/dist-packages/grpc/experimental/aio/_call.py", line 286, in __await__
self._cython_call._status)
grpc.experimental.aio._call.AioRpcError: <AioRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1605096817.110308830","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":4090,"referenced_errors":[{"created":"@1605096817.110303917","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":394,"grpc_status":14}]}"


# Fixed code
def __init__(
    self,
    node_ip_address,
    redis_address,
    dashboard_agent_port,
    redis_password=None,
    temp_dir=None,
    log_dir=None,
    metrics_export_port=None,
    node_manager_port=None,
    object_store_name=None,
    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
    self.log_dir = log_dir
    self.dashboard_agent_port = dashboard_agent_port
    self.metrics_export_port = metrics_export_port
    self.node_manager_port = node_manager_port
    self.object_store_name = object_store_name
    self.raylet_name = raylet_name
    self.node_id = os.environ["RAY_NODE_ID"]
    assert self.node_id, "Empty node id (RAY_NODE_ID)."
    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(
        f"{self.ip}:{self.node_manager_port}"
    )
    self.http_session = None