From 27bebd11a54b09609743c9b589353ed578c42b6c Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 1 Oct 2021 11:13:25 -0700 Subject: [PATCH] Don't evacuate the root cgroup when rootless Signed-off-by: Brad Davidson --- pkg/cli/cmds/init_linux.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/cli/cmds/init_linux.go b/pkg/cli/cmds/init_linux.go index 8a419b736a..6d82fd4fe4 100644 --- a/pkg/cli/cmds/init_linux.go +++ b/pkg/cli/cmds/init_linux.go @@ -7,6 +7,7 @@ import ( "os/signal" "syscall" + "github.com/containerd/containerd/sys" "github.com/erikdubbelboer/gspt" "github.com/pkg/errors" "github.com/rancher/k3s/pkg/version" @@ -20,10 +21,12 @@ func HandleInit() error { return nil } - // The root cgroup has to be empty to enable subtree_control, so evacuate it by placing - // ourselves in the init cgroup. - if err := cgrouputil.EvacuateCgroup2("init"); err != nil { - return errors.Wrap(err, "failed to evacuate root cgroup") + if !sys.RunningInUserNS() { + // The root cgroup has to be empty to enable subtree_control, so evacuate it by placing + // ourselves in the init cgroup. + if err := cgrouputil.EvacuateCgroup2("init"); err != nil { + return errors.Wrap(err, "failed to evacuate root cgroup") + } } pwd, err := os.Getwd()