diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-19 14:22:09 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-26 13:17:06 +0200 |
commit | e27fef335a4a0d2666542028986100a2f60b3e18 (patch) | |
tree | c60a3a502498929a272bf4af8906063dcecacc40 /libpod/util_linux.go | |
parent | 1778bfa5fef337158537a77344300e1a755a7ffe (diff) | |
download | podman-e27fef335a4a0d2666542028986100a2f60b3e18.tar.gz podman-e27fef335a4a0d2666542028986100a2f60b3e18.tar.bz2 podman-e27fef335a4a0d2666542028986100a2f60b3e18.zip |
stats: fix cgroup path for rootless containers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/util_linux.go')
-rw-r--r-- | libpod/util_linux.go | 12 |
1 files changed, 10 insertions, 2 deletions
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 } |