From f6c6c2b2c0ec4569511ac62ad8d2b3c0922ae826 Mon Sep 17 00:00:00 2001 From: Daniel Tomcej Date: Wed, 26 Feb 2020 10:50:07 -0600 Subject: [PATCH] Allow fsnotify to reload config files on k8s (or symlinks) --- pkg/provider/file/file.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/provider/file/file.go b/pkg/provider/file/file.go index 3902ad12c..544ae9193 100644 --- a/pkg/provider/file/file.go +++ b/pkg/provider/file/file.go @@ -110,6 +110,19 @@ func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationCh case <-ctx.Done(): return case evt := <-watcher.Events: + if evt.Op == fsnotify.Remove { + err = watcher.Remove(evt.Name) + if err != nil { + log.WithoutContext().WithField(log.ProviderName, providerName). + Errorf("Could not remove watcher for %s: %s", directory, err) + } + err = watcher.Add(directory) + if err != nil { + log.WithoutContext().WithField(log.ProviderName, providerName). + Errorf("Could not re-add watcher for %s: %s", directory, err) + } + } + if p.Directory == "" { _, evtFileName := filepath.Split(evt.Name) _, confFileName := filepath.Split(p.Filename)