Skip to content

Commit db59489

Browse files
committed
runc delete: fix for rootless cgroup + ro cgroupfs
An issue with runc 1.2.0 was reported to buildkit, in which runc delete returns with an error, with the log saying: > unable to destroy container: unable to remove container's cgroup: open /sys/fs/cgroup/snschvixiy3s74w74fjantrdg: no such file or directory Apparently, what happens is runc is running with no cgroup access (because /sys/fs/cgroup is mounted read-only). In this case error to create a cgroup path (in runc create/run) is ignored, but cgroup removal (in runc delete) is not. This is caused by commit d3d7f7d, which changes the cgroup removal logic in RemovePath. In the current code, if the initial rmdir has failed (in this case with EROFS), but the subsequent os.ReadDir returns ENOENT, it is returned (instead of being ignored -- as the path does not exist and so there is nothing to remove). Here is the minimal fix for the issue. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 8ed1850 commit db59489

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libcontainer/cgroups/utils.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ func RemovePath(path string) error {
257257
}
258258

259259
infos, err := os.ReadDir(path)
260-
if err != nil && !os.IsNotExist(err) {
260+
if err != nil {
261+
if os.IsNotExist(err) {
262+
return nil
263+
}
261264
return err
262265
}
263266
for _, info := range infos {

0 commit comments

Comments
 (0)