Skip to content

Commit

Permalink
cgroup: change cgroup deletion logic on v1
Browse files Browse the repository at this point in the history
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: #9252

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Feb 22, 2021
1 parent 4a6582b commit e87c5b6
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 e87c5b6

Please sign in to comment.