Skip to content

Commit d5b5710

Browse files
Merge pull request #27262 from Honny1/flake-investigation
Fix flaky sysctl completion by handling /proc/sys errors gracefully
2 parents 3e85b2e + 6d63d16 commit d5b5710

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/podman/common/completion.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,12 +1979,16 @@ func AutocompleteSysctl(_ *cobra.Command, _ []string, toComplete string) ([]stri
19791979
var completions []string
19801980
sysPath := "/proc/sys"
19811981

1982-
err := filepath.Walk(sysPath, func(path string, info os.FileInfo, err error) error {
1982+
err := filepath.WalkDir(sysPath, func(path string, d fs.DirEntry, err error) error {
19831983
if err != nil {
1984-
return err
1984+
// /proc/sys is a volatile virtual filesystem whose contents change dynamically.
1985+
// Skip directories on any error (race conditions, permission denied, etc.) to
1986+
// provide partial completion results rather than failing completely.
1987+
// See: https://github.com/containers/podman/issues/27252
1988+
return filepath.SkipDir
19851989
}
19861990

1987-
if !info.IsDir() {
1991+
if !d.IsDir() {
19881992
rel, err := filepath.Rel(sysPath, path)
19891993
if err != nil {
19901994
return err

0 commit comments

Comments
 (0)