diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-06-26 15:25:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-26 15:25:19 +0200 |
commit | 58a1777f518657ff12744bb69ccf2dab3d429625 (patch) | |
tree | a2264182e122e0d0cf29c609bb4856ac5beca7c6 /libpod/container.go | |
parent | da1ef2bdfd52e666a2561e0a012cc3a824938e65 (diff) | |
parent | e27fef335a4a0d2666542028986100a2f60b3e18 (diff) | |
download | podman-58a1777f518657ff12744bb69ccf2dab3d429625.tar.gz podman-58a1777f518657ff12744bb69ccf2dab3d429625.tar.bz2 podman-58a1777f518657ff12744bb69ccf2dab3d429625.zip |
Merge pull request #3374 from giuseppe/cgroups
cgroups: add initial support for cgroups v2
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go index 0c1315843..d05baa7e0 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -14,6 +14,7 @@ import ( "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/lock" "github.com/containers/libpod/pkg/namespaces" + "github.com/containers/libpod/pkg/rootless" "github.com/containers/storage" "github.com/cri-o/ocicni/pkg/ocicni" spec "github.com/opencontainers/runtime-spec/specs-go" @@ -52,6 +53,10 @@ const CgroupfsDefaultCgroupParent = "/libpod_parent" // manager in libpod const SystemdDefaultCgroupParent = "machine.slice" +// SystemdDefaultRootlessCgroupParent is the cgroup parent for the systemd cgroup +// manager in libpod when running as rootless +const SystemdDefaultRootlessCgroupParent = "user.slice" + // JournaldLogging is the string conmon expects to specify journald logging const JournaldLogging = "journald" @@ -1109,6 +1114,10 @@ func (c *Container) CGroupPath() (string, error) { case CgroupfsCgroupsManager: return filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-%s", c.ID())), nil case 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 + } return filepath.Join(c.config.CgroupParent, createUnitName("libpod", c.ID())), nil default: return "", errors.Wrapf(define.ErrInvalidArg, "unsupported CGroup manager %s in use", c.runtime.config.CgroupManager) |