mirror of
https://github.com/containers/podman.git
synced 2025-06-30 15:49:03 +08:00
test: fix race when listing cgroups
A cgroup could have been deleted by the time WalkDir is trying to access it. Ignore the error and continue. Closes: https://github.com/containers/podman/issues/17989 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
@ -47,11 +48,13 @@ var _ = Describe("Podman pod rm", func() {
|
|||||||
// Also check that we don't leak cgroups
|
// Also check that we don't leak cgroups
|
||||||
err := filepath.WalkDir("/sys/fs/cgroup", func(path string, d fs.DirEntry, err error) error {
|
err := filepath.WalkDir("/sys/fs/cgroup", func(path string, d fs.DirEntry, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// A cgroup directory could have been deleted in the meanwhile filepath.WalkDir was
|
||||||
|
// accessing it. If that happens, we just ignore the error.
|
||||||
|
if d.IsDir() && errors.Is(err, os.ErrNotExist) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !d.IsDir() {
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
}
|
|
||||||
if strings.Contains(d.Name(), podid) {
|
if strings.Contains(d.Name(), podid) {
|
||||||
return fmt.Errorf("leaking cgroup path %s", path)
|
return fmt.Errorf("leaking cgroup path %s", path)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user