Only run sandbox in child cgroup if using cgroupv2

Joining a non-leaf node cgroup is only illegal in hierarchical
cgroup accounting.

PiperOrigin-RevId: 493992577
This commit is contained in:
Lucas Manning
2022-12-08 14:16:33 -08:00
committed by gVisor bot
parent d17af25336
commit 2ff7a2750a
+2 -2
View File
@@ -255,8 +255,8 @@ func New(conf *config.Config, args Args) (*Container, error) {
return nil, fmt.Errorf("cannot set up cgroup for root: %w", err)
}
// Join the child cgroup when using cgroupfs. Joining non leaf-node
// cgroups is illegal in Linux and will return EBUSY.
if subCgroup != nil && !conf.SystemdCgroup {
// cgroups is illegal in cgroupsv2 and will return EBUSY.
if subCgroup != nil && !conf.SystemdCgroup && cgroup.IsOnlyV2() {
containerCgroup = subCgroup
} else {
containerCgroup = parentCgroup