Commit 12e675e2 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Don't evacuate the root cgroup when rootless

parent cd5002ea
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"github.com/containerd/containerd/pkg/userns"
"github.com/erikdubbelboer/gspt" "github.com/erikdubbelboer/gspt"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/rancher/k3s/pkg/version" "github.com/rancher/k3s/pkg/version"
...@@ -20,11 +21,13 @@ func HandleInit() error { ...@@ -20,11 +21,13 @@ func HandleInit() error {
return nil return nil
} }
if !userns.RunningInUserNS() {
// The root cgroup has to be empty to enable subtree_control, so evacuate it by placing // The root cgroup has to be empty to enable subtree_control, so evacuate it by placing
// ourselves in the init cgroup. // ourselves in the init cgroup.
if err := cgrouputil.EvacuateCgroup2("init"); err != nil { if err := cgrouputil.EvacuateCgroup2("init"); err != nil {
return errors.Wrap(err, "failed to evacuate root cgroup") return errors.Wrap(err, "failed to evacuate root cgroup")
} }
}
pwd, err := os.Getwd() pwd, err := os.Getwd()
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment