From 3f5039a2d19e5a2b6c176f780ae96018d883051e Mon Sep 17 00:00:00 2001 From: Renaud Gaubert Date: Thu, 8 Nov 2018 20:10:08 +0000 Subject: [PATCH 1/3] Fix pluginwatcher panic on failed startup --- pkg/kubelet/util/pluginwatcher/plugin_watcher.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go index de2addd284..871daebc7d 100644 --- a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go +++ b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go @@ -187,7 +187,9 @@ func (w *Watcher) traversePluginDir(dir string) error { return fmt.Errorf("failed to watch %s, err: %v", path, err) } case mode&os.ModeSocket != 0: + w.wg.Add(1) go func() { + defer w.wg.Done() w.fsWatcher.Events <- fsnotify.Event{ Name: path, Op: fsnotify.Create, From 3a467ff44be136deece5fccf3a18e9fd48be02c8 Mon Sep 17 00:00:00 2001 From: Renaud Gaubert Date: Thu, 8 Nov 2018 20:11:38 +0000 Subject: [PATCH 2/3] Pluginwatcher: log error when walking fs rather than fail --- pkg/kubelet/util/pluginwatcher/plugin_watcher.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go index 871daebc7d..26ebc80bed 100644 --- a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go +++ b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go @@ -175,10 +175,12 @@ func (w *Watcher) init() error { } // Walks through the plugin directory discover any existing plugin sockets. +// Goroutines started here will be waited for in Stop() before cleaning up. func (w *Watcher) traversePluginDir(dir string) error { return w.fs.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil { - 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(); { From 11fef8ba3bae7a3b06f1c4aa4214fb94e3d11987 Mon Sep 17 00:00:00 2001 From: Renaud Gaubert Date: Thu, 8 Nov 2018 23:42:02 +0000 Subject: [PATCH 3/3] Pluginwatcher should prevent kubelet from starting if we cannot watch the plugin root --- pkg/kubelet/util/pluginwatcher/plugin_watcher.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go index 26ebc80bed..88dda9b7c0 100644 --- a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go +++ b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go @@ -176,9 +176,14 @@ func (w *Watcher) init() error { // 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 { return w.fs.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil { + 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 }