diff --git a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go index 4f05f2cf23a..9dad92db845 100644 --- a/pkg/kubelet/util/pluginwatcher/plugin_watcher.go +++ b/pkg/kubelet/util/pluginwatcher/plugin_watcher.go @@ -155,14 +155,17 @@ func (w *Watcher) Stop() error { close(w.stopCh) c := make(chan struct{}) + var once sync.Once + closeFunc := func() { close(c) } go func() { - defer close(c) + defer once.Do(closeFunc) w.wg.Wait() }() select { case <-c: case <-time.After(11 * time.Second): + once.Do(closeFunc) return fmt.Errorf("timeout on stopping watcher") }