summaryrefslogtreecommitdiff
path: root/libpod/util_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-06-26 15:25:19 +0200
committerGitHub <noreply@github.com>2019-06-26 15:25:19 +0200
commit58a1777f518657ff12744bb69ccf2dab3d429625 (patch)
treea2264182e122e0d0cf29c609bb4856ac5beca7c6 /libpod/util_linux.go
parentda1ef2bdfd52e666a2561e0a012cc3a824938e65 (diff)
parente27fef335a4a0d2666542028986100a2f60b3e18 (diff)
downloadpodman-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/util_linux.go')
-rw-r--r--libpod/util_linux.go43
1 files changed, 13 insertions, 30 deletions
diff --git a/libpod/util_linux.go b/libpod/util_linux.go
index 8752eba20..78cbc75a7 100644
--- a/libpod/util_linux.go
+++ b/libpod/util_linux.go
@@ -6,10 +6,9 @@ import (
"fmt"
"strings"
- "github.com/containerd/cgroups"
"github.com/containers/libpod/libpod/define"
- "github.com/containers/libpod/pkg/util"
- spec "github.com/opencontainers/runtime-spec/specs-go"
+ "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"
@@ -35,24 +34,31 @@ 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
}
- return controller.Create(path, &spec.LinuxResources{})
+ return controller.CreateSystemdUnit(path)
}
// 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
}
- return controller.Delete(path)
+ return controller.DeleteByPath(path)
}
// assembleSystemdCgroupName creates a systemd cgroup path given a base and
@@ -71,29 +77,6 @@ func assembleSystemdCgroupName(baseSlice, newSlice string) (string, error) {
return final, nil
}
-// GetV1CGroups gets the V1 cgroup subsystems and then "filters"
-// out any subsystems that are provided by the caller. Passing nil
-// for excludes will return the subsystems unfiltered.
-//func GetV1CGroups(excludes []string) ([]cgroups.Subsystem, error) {
-func GetV1CGroups(excludes []string) cgroups.Hierarchy {
- return func() ([]cgroups.Subsystem, error) {
- var filtered []cgroups.Subsystem
-
- subSystem, err := cgroups.V1()
- if err != nil {
- return nil, err
- }
- for _, s := range subSystem {
- // If the name of the subsystem is not in the list of excludes, then
- // add it as a keeper.
- if !util.StringInSlice(string(s.Name()), excludes) {
- filtered = append(filtered, s)
- }
- }
- return filtered, nil
- }
-}
-
// LabelVolumePath takes a mount path for a volume and gives it an
// selinux label of either shared or not
func LabelVolumePath(path string, shared bool) error {