From eecf4ad9f215aa3b23a29f45f4744c7f3dd63e52 Mon Sep 17 00:00:00 2001 From: kodi Date: Wed, 18 Feb 2026 14:49:07 +0100 Subject: [PATCH] bugfix(containers-dashboard): containers in een systemctl managed pod worden nu ook weergegeven als systemctl managed --- control/app.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/control/app.py b/control/app.py index 2b87cac..1284a64 100644 --- a/control/app.py +++ b/control/app.py @@ -470,6 +470,19 @@ def containers_dashboard(): dashboard = [] defined = find_defined_containers() + # Cache zodat we niet voor elke container opnieuw systemctl doen + unit_active_cache = {} + + def _unit_is_active(unit): + if not unit: + return False + if unit in unit_active_cache: + return unit_active_cache[unit] + code, out = _systemctl(["systemctl", "--user", "is-active", unit]) + ok = (code == 0) or ((out or "").strip() == "active") + unit_active_cache[unit] = ok + return ok + # A) echte containers (runtime) real = _podman_get_json(f"{PODMAN_API_BASE}/libpod/containers/json?all=true") for c in real: @@ -481,13 +494,22 @@ def containers_dashboard(): # Normaliseer naam: Podman kan "/name" geven rname = ((c.get("Names") or ["?"])[0] or "").lstrip("/") - # Managed: systemd als er een .container definitie bestaat, anders podman + # 1) Managed: systemd als er een .container definitie bestaat if rname in defined: c["_dashboard_source"] = "systemd" c["_dashboard_unit"] = f"{rname}.service" c["_dashboard_def_path"] = defined[rname] else: - c["_dashboard_source"] = "podman" + # 2) Extra: zit container in een pod die via systemd (kube/quadlet) draait? + podname = (c.get("PodName") or "").strip() + pod_unit = _map_pod_to_unit(podname) if podname else None + + if pod_unit and _unit_is_active(pod_unit): + c["_dashboard_source"] = "systemd" + c["_dashboard_unit"] = pod_unit + # geen _dashboard_def_path, want dit is geen .container definitie + else: + c["_dashboard_source"] = "podman" dashboard.append(c) @@ -505,6 +527,7 @@ def containers_dashboard(): return dashboard + @app.get("/containers") def list_containers(): # Ook hier ?all=true voor gestopte containers