summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-22 15:48:44 -0500
committerGitHub <noreply@github.com>2021-02-22 15:48:44 -0500
commitc69decc305d746066824701ff073d5b34b744693 (patch)
tree5b91c7609aba8d9661bf34e543dfe4b5c6bdf368 /pkg
parente64669cb96cbb5802ee0d5a0f1aea9638b4d9dd8 (diff)
parente87c5b6c168e0eaf438ca75eb1b1c9ef1e9d246e (diff)
downloadpodman-c69decc305d746066824701ff073d5b34b744693.tar.gz
podman-c69decc305d746066824701ff073d5b34b744693.tar.bz2
podman-c69decc305d746066824701ff073d5b34b744693.zip
Merge pull request #9464 from giuseppe/fix-cgroupv1-stats
cgroup: change cgroup deletion logic on v1
Diffstat (limited to 'pkg')
-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 f563c51a8..608e1647a 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