summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-02-22 10:27:05 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2021-02-22 16:10:15 +0100
commite87c5b6c168e0eaf438ca75eb1b1c9ef1e9d246e (patch)
treea48ef8a3a60f77edad9c51106b0032cec2b21a44
parent4a6582bd86572f0336c82577a0a4f315376c7179 (diff)
downloadpodman-e87c5b6c168e0eaf438ca75eb1b1c9ef1e9d246e.tar.gz
podman-e87c5b6c168e0eaf438ca75eb1b1c9ef1e9d246e.tar.bz2
podman-e87c5b6c168e0eaf438ca75eb1b1c9ef1e9d246e.zip
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>
-rw-r--r--pkg/cgroups/cgroups.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go
index 285fd093a..9d0246314 100644
--- a/pkg/cgroups/cgroups.go
+++ b/pkg/cgroups/cgroups.go
@@ -331,18 +331,24 @@ func Load(path string) (*CgroupControl, error) {
control.additionalControllers = controllers
}
if !cgroup2 {
+ oneExists := false
+ // check that the cgroup exists at least under one controller
for name := range handlers {
p := control.getCgroupv1Path(name)
- if _, err := os.Stat(p); err != nil {
- if os.IsNotExist(err) {
- if rootless.IsRootless() {
- return nil, ErrCgroupV1Rootless
- }
- // compatible with the error code
- // used by containerd/cgroups
- return nil, ErrCgroupDeleted
- }
+ if _, err := os.Stat(p); err == nil {
+ oneExists = true
+ break
+ }
+ }
+
+ // 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