aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-06-09 13:55:03 +0200
committerMatthew Heon <mheon@redhat.com>2021-06-11 11:05:09 -0400
commitb61701acb38d64a3d2622ebb86ad794435e94e54 (patch)
tree8981c2b799e93bb0428895009a33646e4fd28ca2 /libpod
parent41fcd4d8ed9225e18f0d0d7c35b1916d14ceaf00 (diff)
downloadpodman-b61701acb38d64a3d2622ebb86ad794435e94e54.tar.gz
podman-b61701acb38d64a3d2622ebb86ad794435e94e54.tar.bz2
podman-b61701acb38d64a3d2622ebb86ad794435e94e54.zip
container: ignore named hierarchies
when looking up the container cgroup, ignore named hierarchies since containers running systemd as payload will create a sub-cgroup and move themselves there. Closes: https://github.com/containers/podman/issues/10602 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go
index bad91d54f..e14051f80 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -946,6 +946,12 @@ func (c *Container) cGroupPath() (string, error) {
// is the libpod-specific one we're looking for.
//
// See #8397 on the need for the longest-path look up.
+ //
+ // And another workaround for containers running systemd as the payload.
+ // containers running systemd moves themselves into a child subgroup of
+ // the named systemd cgroup hierarchy. Ignore any named cgroups during
+ // the lookup.
+ // See #10602 for more details.
procPath := fmt.Sprintf("/proc/%d/cgroup", c.state.PID)
lines, err := ioutil.ReadFile(procPath)
if err != nil {
@@ -961,6 +967,10 @@ func (c *Container) cGroupPath() (string, error) {
logrus.Debugf("Error parsing cgroup: expected 3 fields but got %d: %s", len(fields), procPath)
continue
}
+ // Ignore named cgroups like name=systemd.
+ if bytes.Contains(fields[1], []byte("=")) {
+ continue
+ }
path := string(fields[2])
if len(path) > len(cgroupPath) {
cgroupPath = path