mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
cgroupv2: fix fs2 driver default path
When the cgroupv2 fs driver is used without setting cgroupsPath, it picks up a path from /proc/self/cgroup. On a host with systemd, such a path can look like (examples from my machines): - /user.slice/user-1000.slice/session-4.scope - /user.slice/user-1000.slice/user@1000.service/gnome-launched-xfce4-terminal.desktop-4260.scope - /user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service This cgroup already contains processes in it, which prevents to enable controllers for a sub-cgroup (writing to cgroup.subtree_control fails with EBUSY or EOPNOTSUPP). Obviously, a parent cgroup (which does not contain tasks) should be used. Fixes opencontainers/runc/issues/2298 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -48,6 +48,11 @@ func defaultDirPath(c *configs.Cgroup) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// The current user scope most probably has tasks in it already,
|
||||
// making it impossible to enable controllers for its sub-cgroup.
|
||||
// A parent cgroup (with no tasks in it) is what we need.
|
||||
ownCgroup = filepath.Dir(ownCgroup)
|
||||
|
||||
return _defaultDirPath(UnifiedMountpoint, cgPath, cgParent, cgName, ownCgroup)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user