mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
list: use Info(), fix race with delete
Since commit 551629417 we 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>
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