Unverified Commit bb4fbc27 authored by k8s-ci-robot's avatar k8s-ci-robot Committed by GitHub

Merge pull request #70821 from RenaudWasTaken/fix-pluginwatcher-panic

Pluginwatcher: Fix panic on failed startup
parents 413ccb15 11fef8ba
...@@ -175,10 +175,17 @@ func (w *Watcher) init() error { ...@@ -175,10 +175,17 @@ func (w *Watcher) init() error {
} }
// Walks through the plugin directory discover any existing plugin sockets. // Walks through the plugin directory discover any existing plugin sockets.
// Goroutines started here will be waited for in Stop() before cleaning up.
// Ignore all errors except root dir not being walkable
func (w *Watcher) traversePluginDir(dir string) error { func (w *Watcher) traversePluginDir(dir string) error {
return w.fs.Walk(dir, func(path string, info os.FileInfo, err error) error { return w.fs.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
return fmt.Errorf("error accessing path: %s error: %v", path, err) if path == dir {
return fmt.Errorf("error accessing path: %s error: %v", path, err)
}
glog.Errorf("error accessing path: %s error: %v", path, err)
return nil
} }
switch mode := info.Mode(); { switch mode := info.Mode(); {
...@@ -187,7 +194,9 @@ func (w *Watcher) traversePluginDir(dir string) error { ...@@ -187,7 +194,9 @@ func (w *Watcher) traversePluginDir(dir string) error {
return fmt.Errorf("failed to watch %s, err: %v", path, err) return fmt.Errorf("failed to watch %s, err: %v", path, err)
} }
case mode&os.ModeSocket != 0: case mode&os.ModeSocket != 0:
w.wg.Add(1)
go func() { go func() {
defer w.wg.Done()
w.fsWatcher.Events <- fsnotify.Event{ w.fsWatcher.Events <- fsnotify.Event{
Name: path, Name: path,
Op: fsnotify.Create, Op: fsnotify.Create,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment