From 10cfd816317789da4393d70ead92ec7c203e1926 Mon Sep 17 00:00:00 2001 From: Peter Hunt~ Date: Fri, 24 Mar 2023 15:09:16 -0400 Subject: [PATCH] libctr/cgroups: don't take init's cgroup into account Sometimes, the init process is not in the root cgroup. This can be noted by GetInitPath, which already scrubs the path of `init.scope`. This was encountered when trying to patch the Kubelet to handle systemd being in a separate cpuset from root (to allow load balance disabling for containers). At present, there's no way to have libcontainer or runc manage cgroups in a hierarchy outside of the one init is in (unless the path contains `init.scope`, which is limiting) Signed-off-by: Peter Hunt (cherry picked from commit 54e20217a86f117037e3f5dd20fed1fdbc34aaf4) --- libcontainer/cgroups/systemd/v1.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/libcontainer/cgroups/systemd/v1.go b/libcontainer/cgroups/systemd/v1.go index 4ec32f7a9ca..4dad32110fe 100644 --- a/libcontainer/cgroups/systemd/v1.go +++ b/libcontainer/cgroups/systemd/v1.go @@ -273,14 +273,7 @@ func getSubsystemPath(slice, unit, subsystem string) (string, error) { return "", err } - initPath, err := cgroups.GetInitCgroup(subsystem) - if err != nil { - return "", err - } - // if pid 1 is systemd 226 or later, it will be in init.scope, not the root - initPath = strings.TrimSuffix(filepath.Clean(initPath), "init.scope") - - return filepath.Join(mountpoint, initPath, slice, unit), nil + return filepath.Join(mountpoint, slice, unit), nil } func (m *legacyManager) Freeze(state configs.FreezerState) error {