From a39633626b55b89a4d439dae31108be515691b26 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 6 Oct 2026 23:46:02 -0400 Subject: [PATCH] fix(docker): a crash-looping service belongs in Needs attention (#5209) failing_services filtered on `(service_trouble(s) or 9) <= 2`; a crash loop ranks 0, which is falsy, so the worst kind of trouble was left out. Test the rank against None. The page test's task error also gains the age_s the _swarm_failures include reads. Co-Authored-By: Claude Opus 5.5 --- plugins/docker/swarm_view.py | 4 +++- tests/plugins/docker/test_docker_page.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/docker/swarm_view.py b/plugins/docker/swarm_view.py index ad2de80..01047a9 100644 --- a/plugins/docker/swarm_view.py +++ b/plugins/docker/swarm_view.py @@ -377,4 +377,6 @@ def failing_services(services: list[dict]) -> list[dict]: """The services that belong in Needs attention: a crash loop, or short of their desired replicas. A healthy service whose failed tasks Swarm has already replaced is history, shown on the service, not a problem now.""" - return [s for s in services_problems_first(services) if (service_trouble(s) or 9) <= 2] + # A crash loop ranks 0, so test the rank against None, not for truth. + return [s for s in services_problems_first(services) + if (t := service_trouble(s)) is not None and t <= 2] diff --git a/tests/plugins/docker/test_docker_page.py b/tests/plugins/docker/test_docker_page.py index ff47963..5014f54 100644 --- a/tests/plugins/docker/test_docker_page.py +++ b/tests/plugins/docker/test_docker_page.py @@ -117,7 +117,7 @@ async def test_a_failing_service_leads_and_the_failures_are_listed(app): "crash_looping": True, "failures_1h": 7, "failures_24h": 9, "tasks_known": True, "trouble_since": now - timedelta(minutes=20), "replicas": [], "previous_tasks": 7, "last_error": {"state": "failed", "error": "task: non-zero exit (1)", "exit_code": 1, - "node": "nas", "at": None}} + "node": "nas", "at": None, "age_s": 120}} failures = [{"kind": "service", "name": "codex_db", "host_id": None, "host": "nas", "count": 9, "at": now - timedelta(minutes=2), "detail": "task: non-zero exit (1)"}, {"kind": "container", "name": "backup", "host_id": "h1", "host": "nas", "count": 1,