cgroup: change cgroup deletion logic on v1

do not raise an error if the cgroup exists at least on one
controller.

Previously it expected the cgroup to exists under all the
controllers.

[NO TESTS NEEDED]

Closes: https://github.com/containers/podman/issues/9252

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2021-02-22 10:27:05 +01:00
parent 4a6582bd86
commit e87c5b6c16

@ -331,19 +331,25 @@ func Load(path string) (*CgroupControl, error) {
control.additionalControllers = controllers control.additionalControllers = controllers
} }
if !cgroup2 { if !cgroup2 {
oneExists := false
// check that the cgroup exists at least under one controller
for name := range handlers { for name := range handlers {
p := control.getCgroupv1Path(name) p := control.getCgroupv1Path(name)
if _, err := os.Stat(p); err != nil { if _, err := os.Stat(p); err == nil {
if os.IsNotExist(err) { oneExists = true
if rootless.IsRootless() { break
return nil, ErrCgroupV1Rootless
}
// compatible with the error code
// used by containerd/cgroups
return nil, ErrCgroupDeleted
}
} }
} }
// if there is no controller at all, raise an error
if !oneExists {
if rootless.IsRootless() {
return nil, ErrCgroupV1Rootless
}
// compatible with the error code
// used by containerd/cgroups
return nil, ErrCgroupDeleted
}
} }
return control, nil return control, nil
} }