From 769c1d54152041b29ea2cc5ac81c6cdfde2ca625 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 7 Mar 2019 11:24:18 -0700 Subject: [PATCH] Fix manifest polling --- pkg/deploy/controller.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/deploy/controller.go b/pkg/deploy/controller.go index 8279b9b84e..f9f3161701 100644 --- a/pkg/deploy/controller.go +++ b/pkg/deploy/controller.go @@ -52,21 +52,15 @@ func WatchFiles(ctx context.Context, skips []string, bases ...string) error { addons.Enqueue("", startKey) addons.Interface().AddHandler(ctx, "addon-start", func(key string, _ *v1.Addon) (runtime.Object, error) { if key == startKey { - if err := w.listFiles(true); err != nil { - return nil, err - } - w.started = true - return nil, nil + go w.start(ctx) } return nil, nil }) - w.start(ctx) return nil } type watcher struct { - started bool addonCache v1.AddonClientCache addons v1.AddonClient bases []string @@ -77,14 +71,17 @@ type watcher struct { } func (w *watcher) start(ctx context.Context) { + force := true for { + if err := w.listFiles(force); err == nil { + force = false + } else { + logrus.Errorf("failed to process config: %v", err) + } select { case <-ctx.Done(): return case <-time.After(15 * time.Second): - if err := w.listFiles(false); err != nil { - logrus.Errorf("failed to process config: %v", err) - } } } } @@ -101,10 +98,6 @@ func (w *watcher) listFiles(force bool) error { } func (w *watcher) listFilesIn(base string, force bool) error { - if !w.started { - return nil - } - files, err := ioutil.ReadDir(base) if os.IsNotExist(err) { return nil