bugfix(containers-dashboard): managed kolom - systemctl containers worden nu als managed systemctl weergegeven en niet als podman (POD containers nog niet)
This commit is contained in:
@@ -3,5 +3,4 @@ WORKDIR /app
|
|||||||
RUN apt-get update && apt-get install -y curl systemd && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y curl systemd && rm -rf /var/lib/apt/lists/*
|
||||||
RUN pip install fastapi uvicorn requests-unixsocket pyyaml pytest httpx
|
RUN pip install fastapi uvicorn requests-unixsocket pyyaml pytest httpx
|
||||||
COPY app.py .
|
COPY app.py .
|
||||||
#COPY tests/ ./tests/
|
|
||||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
|||||||
+18
-7
@@ -468,32 +468,43 @@ def _extract_published_ports(container: dict) -> list[str]:
|
|||||||
@app.get("/containers-dashboard")
|
@app.get("/containers-dashboard")
|
||||||
def containers_dashboard():
|
def containers_dashboard():
|
||||||
dashboard = []
|
dashboard = []
|
||||||
|
defined = find_defined_containers()
|
||||||
|
|
||||||
# A) echte containers (UNCHANGED)
|
# A) echte containers (runtime)
|
||||||
real = _podman_get_json(f"{PODMAN_API_BASE}/libpod/containers/json?all=true")
|
real = _podman_get_json(f"{PODMAN_API_BASE}/libpod/containers/json?all=true")
|
||||||
for c in real:
|
for c in real:
|
||||||
_ensure_container_status_field(c)
|
_ensure_container_status_field(c)
|
||||||
c["_dashboard_source"] = "podman"
|
|
||||||
|
# Published ports: behoud jouw hotfix
|
||||||
c["_dashboard_published_ports"] = _extract_published_ports(c)
|
c["_dashboard_published_ports"] = _extract_published_ports(c)
|
||||||
|
|
||||||
|
# Normaliseer naam: Podman kan "/name" geven
|
||||||
|
rname = ((c.get("Names") or ["?"])[0] or "").lstrip("/")
|
||||||
|
|
||||||
|
# Managed: systemd als er een .container definitie bestaat, anders podman
|
||||||
|
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"
|
||||||
|
|
||||||
dashboard.append(c)
|
dashboard.append(c)
|
||||||
|
|
||||||
# B) Dedup set (HOTFIX 3.3) — exact extraction, no sorting
|
# B) Dedup set: ook genormaliseerd (voorkomt /name vs name doublures)
|
||||||
runtime_names = set((c.get("Names") or ["?"])[0] for c in real)
|
runtime_names = set((((c.get("Names") or ["?"])[0] or "").lstrip("/")) for c in real)
|
||||||
|
|
||||||
# C) defined containers from systemd/*.container (skip duplicates)
|
# C) defined containers from systemd/*.container (skip duplicates)
|
||||||
defined = find_defined_containers()
|
|
||||||
for name, relpath in defined.items():
|
for name, relpath in defined.items():
|
||||||
if name in runtime_names:
|
if name in runtime_names:
|
||||||
continue
|
continue
|
||||||
row = _make_defined_container_dashboard_row(name, relpath)
|
row = _make_defined_container_dashboard_row(name, relpath)
|
||||||
# fill Status from systemd is-active (existing hotfix 3.1 behavior)
|
|
||||||
code, out = _systemctl(["systemctl", "--user", "is-active", f"{name}.service"])
|
code, out = _systemctl(["systemctl", "--user", "is-active", f"{name}.service"])
|
||||||
row["Status"] = (out or "").strip()
|
row["Status"] = (out or "").strip()
|
||||||
dashboard.append(row)
|
dashboard.append(row)
|
||||||
|
|
||||||
return dashboard
|
return dashboard
|
||||||
|
|
||||||
|
|
||||||
@app.get("/containers")
|
@app.get("/containers")
|
||||||
def list_containers():
|
def list_containers():
|
||||||
# Ook hier ?all=true voor gestopte containers
|
# Ook hier ?all=true voor gestopte containers
|
||||||
|
|||||||
Reference in New Issue
Block a user