Merge pull request #3564 from giuseppe/cgroupsv2-no-controllers-last-path

cgroupsv2: do not enable controllers for the last component
This commit is contained in:
OpenShift Merge Robot 2019-07-13 00:21:18 +02:00 committed by GitHub
commit c59d08bc77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -187,8 +187,12 @@ func createCgroupv2Path(path string) (Err error) {
}()
}
}
if err := ioutil.WriteFile(filepath.Join(current, "cgroup.subtree_control"), resByte, 0755); err != nil {
return errors.Wrapf(err, "write %s", filepath.Join(current, "cgroup.subtree_control"))
// We enable the controllers for all the path components except the last one. It is not allowed to add
// PIDs if there are already enabled controllers.
if i < len(elements[3:])-1 {
if err := ioutil.WriteFile(filepath.Join(current, "cgroup.subtree_control"), resByte, 0755); err != nil {
return errors.Wrapf(err, "write %s", filepath.Join(current, "cgroup.subtree_control"))
}
}
}
return nil