fix(services-restart): an LXC container's processes are left out (NetOrk/netork#2750)
driver / standard (pull_request) Failing after 17s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m5s
driver / test (3.12) (pull_request) Successful in 1m23s
driver / test (3.13) (pull_request) Successful in 1m22s
driver / lowest (pull_request) Successful in 44s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m4s
CI / driver (pull_request) Failing after 3m0s
driver / publish (pull_request) Skipped

On a Proxmox node the /proc scan sees every container's processes: an LXC
container updates itself, and its own systemd's units (lxc/<vmid>/ns/...
.service) would read as the host's services needing a restart. They are
left out like Docker's and Podman's: /lxc/<name>/ (Proxmox VE, cgroup v1)
and /lxc.payload.<name>/ (LXC 4 and later). The monitor, lxc.monitor/<name>,
runs the host's lxc-start and still counts.
This commit is contained in:
christianmanivong committed 2026-11-26 18:53:07 +01:00
1 parent 5517464e1f
commit 67ffee4e9e
4 files changed
+44 -7

No files matched your search

+10 -5
View File
@@ -21,10 +21,11 @@ here once, and a driver only carries the command across.
**Units from cgroups.** For the ``/proc`` scan, ``/proc/<pid>/cgroup`` names the
systemd service a process runs in, as for the listening sockets: a process of a
user's own systemd is that user's manager (``user@1000``), one of a container is
left out (the container runs its image's libraries, which no host update
replaces), and one in no service -- a login session, systemd itself -- is listed
as a process. The host's tools name services only, so ``processes`` stays empty
user's own systemd is that user's manager (``user@1000``), one of a container --
Docker, Podman, or LXC as on a Proxmox node -- is left out (the container runs its
own libraries, which no host update replaces, and its own systemd's units are none
of the host's services), and one in no service -- a login session, systemd itself --
is listed as a process. The host's tools name services only, so ``processes`` stays empty
for them.
**Root, or nothing.** Only root sees every process's memory. The script goes to
@@ -84,6 +85,10 @@ _SERVICE_LINE = re.compile(r"^([\w:.@\\-]+)\.service$")
_NEEDRESTART_SVC = re.compile(r"^NEEDRESTART-SVC:\s*(.+?)\s*$")
#: A process of a user's own systemd: that user's manager is what restarts it.
_USER_MANAGER = re.compile(r"/(user@\d+)\.service(?=/|$)")
#: A process inside an LXC container: ``/lxc/<name>/`` (Proxmox VE, which nests the
#: container's own cgroups under ``ns``; cgroup v1) or ``/lxc.payload.<name>/`` (LXC 4
#: and later). Not ``/lxc.monitor/<name>``: ``lxc-start`` runs the host's binary.
_LXC = re.compile(r"^/lxc(?:/|\.payload\.)[^/]+(?:/|$)")
_SERVICE_SUFFIX = ".service"
@@ -130,7 +135,7 @@ def _maps(sections: dict[str, list[str]]) -> tuple[list[str], list[RestartProces
if not pid.isdigit():
continue
path = paths.get(int(pid))
if _container(path):
if _container(path) or _LXC.match(path or ""):
continue
unit = _process_unit(path)
if unit: