diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-09-15 10:46:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 10:46:33 -0400 |
commit | c0cde378298bd8d5183155c8f62aae574be069eb (patch) | |
tree | 81d83de3be64cad8eefc0a56391d06ca5c71f253 | |
parent | 81f41ca0d2a0acd9896bb60b1096baa236725dec (diff) | |
parent | 44abc17977165ceb6b7d84efe4b9c62c8fbb2ac1 (diff) | |
download | podman-c0cde378298bd8d5183155c8f62aae574be069eb.tar.gz podman-c0cde378298bd8d5183155c8f62aae574be069eb.tar.bz2 podman-c0cde378298bd8d5183155c8f62aae574be069eb.zip |
Merge pull request #11567 from giuseppe/cgroups-split-with-pods
libpod: honor --cgroups=split also with pods
-rw-r--r-- | libpod/container_internal_linux.go | 3 | ||||
-rw-r--r-- | test/e2e/run_test.go | 53 |
2 files changed, 32 insertions, 24 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index ae029dc62..4194a0d93 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -2490,9 +2490,6 @@ func (c *Container) getOCICgroupPath() (string, error) { case c.config.NoCgroups: return "", nil case c.config.CgroupsMode == cgroupSplit: - if c.config.CgroupParent != "" { - return c.config.CgroupParent, nil - } selfCgroup, err := utils.GetOwnCgroup() if err != nil { return "", err diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index cb61aba21..ec4b0d997 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -1296,31 +1296,42 @@ USER mail`, BB) SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users") SkipIfRemote("--cgroups=split cannot be used in remote mode") - container := podmanTest.Podman([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) - container.WaitWithDefaultTimeout() - Expect(container).Should(Exit(0)) - lines := container.OutputToStringArray() - - cgroup := "" - for _, line := range lines { - parts := strings.SplitN(line, ":", 3) - if !CGROUPSV2 { - // ignore unified on cgroup v1. - // both runc and crun do not set it. - // crun does not set named hierarchies. - if parts[1] == "" || strings.Contains(parts[1], "name=") { + checkLines := func(lines []string) { + cgroup := "" + for _, line := range lines { + parts := strings.SplitN(line, ":", 3) + if len(parts) < 2 { continue } + if !CGROUPSV2 { + // ignore unified on cgroup v1. + // both runc and crun do not set it. + // crun does not set named hierarchies. + if parts[1] == "" || strings.Contains(parts[1], "name=") { + continue + } + } + if parts[2] == "/" { + continue + } + if cgroup == "" { + cgroup = parts[2] + continue + } + Expect(cgroup).To(Equal(parts[2])) } - if parts[2] == "/" { - continue - } - if cgroup == "" { - cgroup = parts[2] - continue - } - Expect(cgroup).To(Equal(parts[2])) } + + container := podmanTest.Podman([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) + container.WaitWithDefaultTimeout() + Expect(container).Should(Exit(0)) + checkLines(container.OutputToStringArray()) + + // check that --cgroups=split is honored also when a container runs in a pod + container = podmanTest.Podman([]string{"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) + container.WaitWithDefaultTimeout() + Expect(container).Should(Exit(0)) + checkLines(container.OutputToStringArray()) }) It("podman run with cgroups=disabled runs without cgroups", func() { |