Merge pull request #18277 from giuseppe/fix-race-test-rm-cgroup

test: fix race when listing cgroups
This commit is contained in:
OpenShift Merge Robot 2023-04-20 07:03:41 -04:00 committed by GitHub
commit 85d383bb35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package integration
import (
"errors"
"fmt"
"io/fs"
"os"
@ -47,11 +48,13 @@ var _ = Describe("Podman pod rm", func() {
// Also check that we don't leak cgroups
err := filepath.WalkDir("/sys/fs/cgroup", func(path string, d fs.DirEntry, err error) error {
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
}
if !d.IsDir() {
Expect(err).ToNot(HaveOccurred())
}
if strings.Contains(d.Name(), podid) {
return fmt.Errorf("leaking cgroup path %s", path)
}