summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-10-12 12:16:32 +0200
committerMatthew Heon <matthew.heon@pm.me>2021-10-19 15:56:35 -0400
commitb470de05b072fff1d7a70459a0d4543d0dbc9b0a (patch)
treec6ee87c2e99731158d95d4dd5faa72acbb3c6f35
parent8b87793d4878026d5d4f734409f33fe873160115 (diff)
downloadpodman-b470de05b072fff1d7a70459a0d4543d0dbc9b0a.tar.gz
podman-b470de05b072fff1d7a70459a0d4543d0dbc9b0a.tar.bz2
podman-b470de05b072fff1d7a70459a0d4543d0dbc9b0a.zip
cgroups: use cgroup.controllers to read controllers
use the cgroup.controllers file instead of cgroup.subtree_control to read the list of controllers available in the current cgroup. Closes: https://github.com/containers/podman/issues/11931 [NO TESTS NEEDED] we have disabled this test in the CI because it is difficult to know what controllers are going to be enabled for rootless under all conditions we test. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--pkg/cgroups/cgroups.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go
index 4bb8de69b..f1ef538e4 100644
--- a/pkg/cgroups/cgroups.go
+++ b/pkg/cgroups/cgroups.go
@@ -129,8 +129,8 @@ func init() {
func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool) ([]controller, error) {
if cgroup2 {
controllers := []controller{}
- subtreeControl := cgroupRoot + "/cgroup.subtree_control"
- // rootless cgroupv2: check available controllers for current user ,systemd or servicescope will inherit
+ controllersFile := cgroupRoot + "/cgroup.controllers"
+ // rootless cgroupv2: check available controllers for current user, systemd or servicescope will inherit
if rootless.IsRootless() {
userSlice, err := getCgroupPathForCurrentProcess()
if err != nil {
@@ -138,13 +138,13 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
}
//userSlice already contains '/' so not adding here
basePath := cgroupRoot + userSlice
- subtreeControl = fmt.Sprintf("%s/cgroup.subtree_control", basePath)
+ controllersFile = fmt.Sprintf("%s/cgroup.controllers", basePath)
}
- subtreeControlBytes, err := ioutil.ReadFile(subtreeControl)
+ controllersFileBytes, err := ioutil.ReadFile(controllersFile)
if err != nil {
- return nil, errors.Wrapf(err, "failed while reading controllers for cgroup v2 from %q", subtreeControl)
+ return nil, errors.Wrapf(err, "failed while reading controllers for cgroup v2 from %q", controllersFile)
}
- for _, controllerName := range strings.Fields(string(subtreeControlBytes)) {
+ for _, controllerName := range strings.Fields(string(controllersFileBytes)) {
c := controller{
name: controllerName,
symlink: false,