diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-29 10:53:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 10:53:41 -0400 |
commit | 6ac009d5304127f6758be157c7302646e5a481e5 (patch) | |
tree | 75f186484198eb84f18c575e86032e25d5e819a3 /libpod/container.go | |
parent | 771c887010709cdf718be252ca91a852c6735da7 (diff) | |
parent | 6ee5f740a4ecb70636b888e78b02065ee984636c (diff) | |
download | podman-6ac009d5304127f6758be157c7302646e5a481e5.tar.gz podman-6ac009d5304127f6758be157c7302646e5a481e5.tar.bz2 podman-6ac009d5304127f6758be157c7302646e5a481e5.zip |
Merge pull request #6666 from giuseppe/conmon-delegate
podman: add new cgroup mode split
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/libpod/container.go b/libpod/container.go index c85249676..20688e3ee 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -17,6 +17,7 @@ import ( "github.com/containers/libpod/libpod/lock" "github.com/containers/libpod/pkg/namespaces" "github.com/containers/libpod/pkg/rootless" + "github.com/containers/libpod/utils" "github.com/containers/storage" "github.com/cri-o/ocicni/pkg/ocicni" spec "github.com/opencontainers/runtime-spec/specs-go" @@ -1089,10 +1090,25 @@ func (c *Container) NamespacePath(linuxNS LinuxNS) (string, error) { //nolint:in // CGroupPath returns a cgroups "path" for a given container. func (c *Container) CGroupPath() (string, error) { - switch c.runtime.config.Engine.CgroupManager { - case config.CgroupfsCgroupsManager: + switch { + case c.config.CgroupsMode == cgroupSplit: + if c.config.CgroupParent != "" { + return "", errors.Errorf("cannot specify cgroup-parent with cgroup-mode %q", cgroupSplit) + } + cg, err := utils.GetCgroupProcess(c.state.ConmonPID) + if err != nil { + return "", err + } + // Use the conmon cgroup for two reasons: we validate the container + // delegation was correct, and the conmon cgroup doesn't change at runtime + // while we are not sure about the container that can create sub cgroups. + if !strings.HasSuffix(cg, "supervisor") { + return "", errors.Errorf("invalid cgroup for conmon %q", cg) + } + return strings.TrimSuffix(cg, "/supervisor") + "/container", nil + case c.runtime.config.Engine.CgroupManager == config.CgroupfsCgroupsManager: return filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-%s", c.ID())), nil - case config.SystemdCgroupsManager: + case c.runtime.config.Engine.CgroupManager == config.SystemdCgroupsManager: if rootless.IsRootless() { uid := rootless.GetRootlessUID() parts := strings.SplitN(c.config.CgroupParent, "/", 2) |