runsc: allow to run rootless containers on cgroupV2

Before cl/402392291 and cl/402614820, it worked without any problem.

In this case, we just ignore a cgroup configuration. We do the same thing,
when we don't have permissions to create new cgroups on cgroupV1.

PiperOrigin-RevId: 402913129
This commit is contained in:
Andrei Vagin
2021-10-13 13:51:18 -07:00
committed by gVisor bot
parent b74bbe11e6
commit 8221893794
+4 -1
View File
@@ -1278,7 +1278,10 @@ func (c *Container) setupCgroupForSubcontainer(conf *config.Config, spec *specs.
// no cgroups was configured.
func cgroupInstall(conf *config.Config, cg *cgroup.Cgroup, res *specs.LinuxResources) (*cgroup.Cgroup, error) {
// TODO(gvisor.dev/issue/3481): Remove when cgroups v2 is supported.
if !conf.Rootless && cgroup.IsOnlyV2() {
if cgroup.IsOnlyV2() {
if conf.Rootless {
return nil, nil
}
return nil, fmt.Errorf("cgroups V2 is not yet supported. Enable cgroups V1 and retry")
}
if err := cg.Install(res); err != nil {