mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
list: use Info(), fix race with delete
Since commit551629417we can (and should) use Info() to get access to file stat. Do this. While going over directory entries, a parallel runc delete can remove an entry, and with the current code it results in a fatal error (which was not observed in practice, but looks quite possible). To fix, add a special case to continue on ErrNotExist. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> (cherry picked from commit1a3ee4966c) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -130,8 +130,12 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
||||
if !item.IsDir() {
|
||||
continue
|
||||
}
|
||||
st, err := os.Stat(filepath.Join(absRoot, item.Name()))
|
||||
st, err := item.Info()
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
// Possible race with runc delete.
|
||||
continue
|
||||
}
|
||||
fatal(err)
|
||||
}
|
||||
// This cast is safe on Linux.
|
||||
|
||||
Reference in New Issue
Block a user