Fix issue in checking domain socket for plugin watcher

Due to recent os.Stat() issue for Windows 20H2, added the logic to use
    os.Lstat() if os.Stat() fails for Windows

Change-Id: Ic9fc07ecc6e9c2984e854ac77121ff61c8e0d041
This commit is contained in:
Jing Xu 2021-03-03 11:39:26 -08:00
parent 2f263b24a7
commit d669cb1b17

View File

@ -159,7 +159,13 @@ func (w *Watcher) traversePluginDir(dir string) error {
func (w *Watcher) handleCreateEvent(event fsnotify.Event) error {
klog.V(6).Infof("Handling create event: %v", event)
fi, err := os.Lstat(event.Name)
fi, err := os.Stat(event.Name)
// TODO: This is a workaround for Windows 20H2 issue for os.Stat(). Please see
// microsoft/Windows-Containers#97 for details.
// Once the issue is resvolved, the following os.Lstat() is not needed.
if err != nil && runtime.GOOS == "windows" {
fi, err = os.Lstat(event.Name)
}
if err != nil {
return fmt.Errorf("stat file %s failed: %v", event.Name, err)
}