From 8d8c7df569fbca713a92d89e03ca0ba8f5f412fb Mon Sep 17 00:00:00 2001 From: Richard Connon Date: Fri, 28 Sep 2018 12:06:43 +0100 Subject: [PATCH] Log failure to close fsnotify handle (#1250) --- api/agent/agent.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/agent/agent.go b/api/agent/agent.go index e88c0e4e2..ede44c8f9 100644 --- a/api/agent/agent.go +++ b/api/agent/agent.go @@ -1105,7 +1105,11 @@ func inotifyAwait(ctx context.Context, iofsDir string) error { if err != nil { return fmt.Errorf("error getting fsnotify watcher: %v", err) } - defer fsWatcher.Close() + defer func() { + if err := fsWatcher.Close(); err != nil { + common.Logger(ctx).WithError(err).Error("Failed to close inotify watcher") + } + }() err = fsWatcher.Add(iofsDir) if err != nil {