Skip to main content

remove_host_container_cgroup

Function remove_host_container_cgroup 

Source
pub fn remove_host_container_cgroup(container_id: &str)
Expand description

Best-effort removal of the host-mode container cgroup at /sys/fs/cgroup/zlayer/containers/<container_id>.

libcontainer’s delete() normally reaps the leaf cgroup, but systemd-cgroup races and cgroup-v2 unified hiccups can leave a stale, empty directory behind. Because the next create_container rebuilds the same <root>/containers/<id> path, that orphan trips libcontainer’s build() with could not delete on restart/scale. This reaps it directly at the real path (the old read_dir-the-mount scan never matched two levels down).

Idempotent (NotFound is ignored) and best-effort (EBUSY/other errors are logged, not propagated). No-op on non-Linux.