Skip to content

Commit

Permalink
Merge pull request #9464 from giuseppe/fix-cgroupv1-stats
Browse files Browse the repository at this point in the history
cgroup: change cgroup deletion logic on v1
  • Loading branch information
openshift-merge-robot authored Feb 22, 2021
2 parents e64669c + e87c5b6 commit c69decc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pkg/cgroups/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c69decc

Please sign in to comment.