diff --git a/app/nodes.py b/app/nodes.py index cf29d40..891f56d 100644 --- a/app/nodes.py +++ b/app/nodes.py @@ -117,7 +117,7 @@ def list_nodes() -> list: r = httpx.get(f"{coordinator_url}/api/nodes", timeout=5.0) r.raise_for_status() coord_nodes: list[dict] = r.json() - except (httpx.HTTPError, httpx.ConnectError) as exc: + except httpx.HTTPError as exc: logger.warning("Coordinator unreachable: %s", exc) return [] @@ -125,7 +125,8 @@ def list_nodes() -> list: sr = httpx.get(f"{coordinator_url}/api/services", timeout=5.0) sr.raise_for_status() services_data: list[dict] = sr.json() - except Exception: + except httpx.HTTPError: + logger.warning("Services API unreachable for %s, skipping", coordinator_url) services_data = [] # Build per-node, per-GPU running services map diff --git a/tests/test_nodes.py b/tests/test_nodes.py index 2b6e74a..52df098 100644 --- a/tests/test_nodes.py +++ b/tests/test_nodes.py @@ -6,6 +6,7 @@ from pathlib import Path import pytest import yaml from fastapi.testclient import TestClient +from unittest.mock import MagicMock, patch @pytest.fixture(autouse=True) @@ -47,7 +48,6 @@ def test_list_nodes_returns_empty_when_no_coordinator(client): assert r.json() == [] -from unittest.mock import MagicMock, patch def _fake_nodes_response(nodes_json: list, services_json: list | None = None):