summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-12-04 11:13:40 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-12-04 11:13:40 +0100
commit3f1675d9026343c73a456a483ce633ffd5d00712 (patch)
tree13b05905cb6ef3ba34eb04af81741ac413d25baf /libpod/container.go
parent10f733497f37c6ed85756ba95f6e75f3443a90af (diff)
downloadpodman-3f1675d9026343c73a456a483ce633ffd5d00712.tar.gz
podman-3f1675d9026343c73a456a483ce633ffd5d00712.tar.bz2
podman-3f1675d9026343c73a456a483ce633ffd5d00712.zip
libpod: fix stats for rootless pods
honor the systemd parent directory when specified. Closes: https://github.com/containers/libpod/issues/4634 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/libpod/container.go b/libpod/container.go
index d978e4e38..dcec3ee50 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -6,6 +6,7 @@ import (
"net"
"os"
"path/filepath"
+ "strings"
"time"
"github.com/containernetworking/cni/pkg/types"
@@ -1072,7 +1073,14 @@ func (c *Container) CGroupPath() (string, error) {
case define.SystemdCgroupsManager:
if rootless.IsRootless() {
uid := rootless.GetRootlessUID()
- return filepath.Join(c.config.CgroupParent, fmt.Sprintf("user-%d.slice/user@%d.service/user.slice", uid, uid), createUnitName("libpod", c.ID())), nil
+ parts := strings.SplitN(c.config.CgroupParent, "/", 2)
+
+ dir := ""
+ if len(parts) > 1 {
+ dir = parts[1]
+ }
+
+ return filepath.Join(parts[0], fmt.Sprintf("user-%d.slice/user@%d.service/user.slice/%s", uid, uid, dir), createUnitName("libpod", c.ID())), nil
}
return filepath.Join(c.config.CgroupParent, createUnitName("libpod", c.ID())), nil
default: