From e27fef335a4a0d2666542028986100a2f60b3e18 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 19 Jun 2019 14:22:09 +0200 Subject: stats: fix cgroup path for rootless containers Signed-off-by: Giuseppe Scrivano --- libpod/util_linux.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libpod/util_linux.go') diff --git a/libpod/util_linux.go b/libpod/util_linux.go index 77dcf86f6..78cbc75a7 100644 --- a/libpod/util_linux.go +++ b/libpod/util_linux.go @@ -8,6 +8,7 @@ import ( "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/cgroups" + "github.com/containers/libpod/pkg/rootless" "github.com/opencontainers/selinux/go-selinux/label" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -33,9 +34,16 @@ func systemdSliceFromPath(parent, name string) (string, error) { return cgroupPath, nil } +func getDefaultSystemdCgroup() string { + if rootless.IsRootless() { + return SystemdDefaultRootlessCgroupParent + } + return SystemdDefaultCgroupParent +} + // makeSystemdCgroup creates a systemd CGroup at the given location. func makeSystemdCgroup(path string) error { - controller, err := cgroups.NewSystemd(SystemdDefaultCgroupParent) + controller, err := cgroups.NewSystemd(getDefaultSystemdCgroup()) if err != nil { return err } @@ -45,7 +53,7 @@ func makeSystemdCgroup(path string) error { // deleteSystemdCgroup deletes the systemd cgroup at the given location func deleteSystemdCgroup(path string) error { - controller, err := cgroups.NewSystemd(SystemdDefaultCgroupParent) + controller, err := cgroups.NewSystemd(getDefaultSystemdCgroup()) if err != nil { return err } -- cgit v1.2.3-54-g00ecf