diff --git a/control/app_containers.py b/control/app_containers.py index bed6ad9..6018878 100644 --- a/control/app_containers.py +++ b/control/app_containers.py @@ -14,7 +14,6 @@ from fastapi.responses import StreamingResponse from pydantic import BaseModel, Field from common import ( _helper_call, - _map_pod_to_unit, _podman_action_post, _podman_get_json, _podman_get_text, @@ -412,21 +411,8 @@ def init_containers_router( dashboard = [] defined = find_defined_containers() - # Cache zodat we niet voor elke container opnieuw systemctl doen - unit_active_cache = {} - stats_by_name = _STATS_CACHE_BY_NAME - def _unit_is_active(unit): - if not unit: - return False - if unit in unit_active_cache: - return unit_active_cache[unit] - code, out = systemctl_func(["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(session, f"{podman_api_base}/libpod/containers/json?all=true") for c in real: @@ -448,22 +434,18 @@ def init_containers_router( c["_dashboard_mem_usage"] = st.get("mem_usage") c["_dashboard_mem_perc"] = st.get("mem_perc") - # 1) Managed: systemd als er een .container definitie bestaat - if rname in defined: + # Classificatie: PODMAN_SYSTEMD_UNIT label is ground truth + labels = c.get("Labels") or {} + podman_unit = labels.get("PODMAN_SYSTEMD_UNIT") or "" + if podman_unit: c["_dashboard_source"] = "systemd" - c["_dashboard_unit"] = f"{rname}.service" - c["_dashboard_def_path"] = defined[rname] + c["_dashboard_unit"] = podman_unit else: - # 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 + c["_dashboard_source"] = "podman" - 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" + # Definitiepad: onafhankelijk van classificatie + if rname in defined: + c["_dashboard_def_path"] = defined[rname] dashboard.append(c)