utils: ignore unified on cgroupv1 if not present

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2021-02-10 19:33:34 +01:00
parent f4fd25a005
commit 9196a5ce36
No known key found for this signature in database
GPG key ID: E4730F97F60286ED

View file

@ -150,6 +150,11 @@ func moveUnderCgroup(cgroup, subtree string, processes []uint32) error {
// If it is not using unified mode, the cgroup v2 hierarchy is
// usually mounted under /sys/fs/cgroup/unified
cgroupRoot = filepath.Join(cgroupRoot, "unified")
// Ignore the unified mount if it doesn't exist
if _, err := os.Stat(cgroupRoot); err != nil && os.IsNotExist(err) {
continue
}
} else if parts[1] != "" {
// Assume the controller is mounted at /sys/fs/cgroup/$CONTROLLER.
controller := strings.TrimPrefix(parts[1], "name=")