diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-08-08 16:27:48 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-08 21:03:20 +0000 |
commit | 9bd991f477ab2bb4428df6286452516c3deb970e (patch) | |
tree | d7fdad97dfbfe496183fcfb06be48f67c41077a7 | |
parent | bb45de5605e263cba6d869eeba5426551c940346 (diff) | |
download | podman-9bd991f477ab2bb4428df6286452516c3deb970e.tar.gz podman-9bd991f477ab2bb4428df6286452516c3deb970e.tar.bz2 podman-9bd991f477ab2bb4428df6286452516c3deb970e.zip |
Fix CGroupFS cgroup manager cgroup creation for pods
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #1237
Approved by: rhatdan
-rw-r--r-- | libpod/runtime_ctr.go | 3 | ||||
-rw-r--r-- | libpod/runtime_pod_linux.go | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 709775e4a..ffad9d649 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -85,6 +85,9 @@ func (r *Runtime) NewContainer(ctx context.Context, rSpec *spec.Spec, options .. if err != nil { return nil, errors.Wrapf(err, "error retrieving pod %s cgroup", pod.ID()) } + if podCgroup == "" { + return nil, errors.Wrapf(ErrInternal, "pod %s cgroup is not set", pod.ID()) + } ctr.config.CgroupParent = podCgroup } else { ctr.config.CgroupParent = CgroupfsDefaultCgroupParent diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go index 3355e4322..58affa45f 100644 --- a/libpod/runtime_pod_linux.go +++ b/libpod/runtime_pod_linux.go @@ -57,14 +57,6 @@ func (r *Runtime) NewPod(options ...PodCreateOption) (*Pod, error) { } else if strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") { return nil, errors.Wrapf(ErrInvalidArg, "systemd slice received as cgroup parent when using cgroupfs") } - // Creating CGroup path is currently a NOOP until proper systemd - // cgroup management is merged - case SystemdCgroupsManager: - if pod.config.CgroupParent == "" { - pod.config.CgroupParent = SystemdDefaultCgroupParent - } else if len(pod.config.CgroupParent) < 6 || !strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") { - return nil, errors.Wrapf(ErrInvalidArg, "did not receive systemd slice as cgroup parent when using systemd to manage cgroups") - } // 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 @@ -72,6 +64,14 @@ func (r *Runtime) NewPod(options ...PodCreateOption) (*Pod, error) { if pod.config.UsePodCgroup { pod.state.CgroupPath = filepath.Join(pod.config.CgroupParent, pod.ID()) } + case SystemdCgroupsManager: + if pod.config.CgroupParent == "" { + pod.config.CgroupParent = SystemdDefaultCgroupParent + } else if len(pod.config.CgroupParent) < 6 || !strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") { + return nil, errors.Wrapf(ErrInvalidArg, "did not receive systemd slice as cgroup parent when using systemd to manage cgroups") + } + // Creating CGroup path is currently a NOOP until proper systemd + // cgroup management is merged default: return nil, errors.Wrapf(ErrInvalidArg, "unsupported CGroup manager: %s - cannot validate cgroup parent", r.config.CgroupManager) } |