diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-06 09:39:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-06 09:39:03 -0400 |
commit | 176ae99187de9068670dac1fb3ec30e11cd3dd93 (patch) | |
tree | b1cb4cd71bf7ea541f3336ee2a79d83eacdb22c2 /libpod/runtime_pod_linux.go | |
parent | 5fa31e10e364e57f7bdc4bb00f483b7f6a631ee0 (diff) | |
parent | 27ac750c7d949fc5922c4a11bf3e8e4606dd2a04 (diff) | |
download | podman-176ae99187de9068670dac1fb3ec30e11cd3dd93.tar.gz podman-176ae99187de9068670dac1fb3ec30e11cd3dd93.tar.bz2 podman-176ae99187de9068670dac1fb3ec30e11cd3dd93.zip |
Merge pull request #10234 from giuseppe/fix-cgroupfs-pod
cgroup: fix rootless --cgroup-parent with pods
Diffstat (limited to 'libpod/runtime_pod_linux.go')
-rw-r--r-- | libpod/runtime_pod_linux.go | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go index cf48a9453..4ede23cac 100644 --- a/libpod/runtime_pod_linux.go +++ b/libpod/runtime_pod_linux.go @@ -75,17 +75,20 @@ func (r *Runtime) NewPod(ctx context.Context, options ...PodCreateOption) (_ *Po // Check CGroup parent sanity, and set it if it was not set switch r.config.Engine.CgroupManager { case config.CgroupfsCgroupsManager: - if pod.config.CgroupParent == "" { - pod.config.CgroupParent = CgroupfsDefaultCgroupParent - } else if strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") { - return nil, errors.Wrapf(define.ErrInvalidArg, "systemd slice received as cgroup parent when using cgroupfs") - } - // If we are set to use pod cgroups, set the cgroup parent that - // all containers in the pod will share - // No need to create it with cgroupfs - the first container to - // launch should do it for us - if pod.config.UsePodCgroup { - pod.state.CgroupPath = filepath.Join(pod.config.CgroupParent, pod.ID()) + canUseCgroup := !rootless.IsRootless() || isRootlessCgroupSet(pod.config.CgroupParent) + if canUseCgroup { + if pod.config.CgroupParent == "" { + pod.config.CgroupParent = CgroupfsDefaultCgroupParent + } else if strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") { + return nil, errors.Wrapf(define.ErrInvalidArg, "systemd slice received as cgroup parent when using cgroupfs") + } + // If we are set to use pod cgroups, set the cgroup parent that + // all containers in the pod will share + // No need to create it with cgroupfs - the first container to + // launch should do it for us + if pod.config.UsePodCgroup { + pod.state.CgroupPath = filepath.Join(pod.config.CgroupParent, pod.ID()) + } } case config.SystemdCgroupsManager: if pod.config.CgroupParent == "" { |