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

+29
View File
@@ -115,6 +115,35 @@ class TestTheMapsScan:
assert reading == {"source": "maps", "units": [], "processes": []}
@pytest.mark.parametrize(
"cgroup",
[
# Proxmox VE: the container's own systemd, under lxc/<vmid>/ns.
"0::/lxc/101/ns/system.slice/nginx.service",
"0::/lxc/101/ns/init.scope",
# LXC 4 and later by default.
"0::/lxc.payload.web/system.slice/nginx.service",
# cgroup v1, systemd's hierarchy.
"12:name=systemd:/lxc/web/system.slice/nginx.service",
],
)
def test_an_lxc_container_is_left_out(self, cgroup):
"""A Proxmox node's containers update themselves: the host sees their processes'
mappings, and their own systemd's units, which are no services of the host's."""
cgroups = f"2100 {cgroup}\n"
reading = parse_services_restart(_wire(("maps", "2100 nginx\n"), ("cgroups", cgroups)))
assert reading == {"source": "maps", "units": [], "processes": []}
def test_an_lxc_monitor_is_the_hosts(self):
"""``lxc-start`` runs the host's own binary, outside the container."""
reading = parse_services_restart(
_wire(("maps", "2090 lxc-start\n"), ("cgroups", "2090 0::/lxc.monitor/101\n"))
)
assert reading["processes"] == [{"pid": 2090, "name": "lxc-start"}]
def test_a_process_gone_before_its_cgroup_was_read_has_no_unit(self):
reading = parse_services_restart(_wire(("maps", "4242 cron\n"), ("cgroups", "")))