From 3f55b068808aaa2df224cd730acb79bec9cb898a Mon Sep 17 00:00:00 2001 From: Connor Pierce Date: Thu, 15 Oct 2026 12:03:45 -0300 Subject: [PATCH] Don't log dashboard link when the dashboard is not enabled A Scheduler created without dashboard/dashboard_address still starts its HTTP server for /health and /metrics, which registers it as the "dashboard" service, so startup logged "dashboard at: .../status" even though the Bokeh routes were never attached and the URL returned 404. Record whether the dashboard was requested (before the missing-bokeh fallback, which still serves a helpful /status page) and only log the link in that case. Closes Issue #7994 --- distributed/scheduler.py | 3 +++ distributed/tests/test_scheduler.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/distributed/scheduler.py b/distributed/scheduler.py index 92f22b807a..e9a3aa9a7c 100644 --- a/distributed/scheduler.py +++ b/distributed/scheduler.py @@ -3995,6 +3995,7 @@ def __init__( http_server_modules = dask.config.get("distributed.scheduler.http.routes") show_dashboard = dashboard or (dashboard is None and dashboard_address) + self._dashboard_requested = bool(show_dashboard) # install vanilla route if show_dashboard but bokeh is not installed if show_dashboard: try: @@ -4432,6 +4433,8 @@ async def start_unsafe(self) -> Self: for listener in self.listeners: logger.info(" Scheduler at: %25s", listener.contact_address) for name, server in self.services.items(): + if name == "dashboard" and not self._dashboard_requested: + continue if name == "dashboard": addr = get_address_host(listener.contact_address) try: diff --git a/distributed/tests/test_scheduler.py b/distributed/tests/test_scheduler.py index 3873575c12..aaef392374 100644 --- a/distributed/tests/test_scheduler.py +++ b/distributed/tests/test_scheduler.py @@ -2710,6 +2710,22 @@ async def test_dashboard_address(): assert s.services["dashboard"].port == 8901 +@gen_test() +async def test_dashboard_link_not_logged_when_dashboard_disabled(): + with captured_logger("distributed.scheduler") as log: + async with Scheduler(dashboard_address=None, dashboard=None, port=0): + pass + assert "dashboard at" not in log.getvalue() + + +@gen_test() +async def test_dashboard_link_logged_when_dashboard_enabled(): + with captured_logger("distributed.scheduler") as log: + async with Scheduler(dashboard_address=":0", port=0): + pass + assert re.search(r"dashboard at:\s*http://", log.getvalue()) + + def test_stop_services(): pytest.importorskip("bokeh") loop_runner = LoopRunner()