From a3d337491fd140ffa53150562f8cb5fa4135fd79 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Wed, 17 Mar 2021 15:04:58 +0800 Subject: [PATCH] Fix watchForLockfileContention memory leak --- cmd/kubelet/app/server_linux.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/kubelet/app/server_linux.go b/cmd/kubelet/app/server_linux.go index c22e24d5312..3eef6f13d9e 100644 --- a/cmd/kubelet/app/server_linux.go +++ b/cmd/kubelet/app/server_linux.go @@ -29,6 +29,7 @@ func watchForLockfileContention(path string, done chan struct{}) error { } if err = watcher.AddWatch(path, inotify.InOpen|inotify.InDeleteSelf); err != nil { klog.ErrorS(err, "Unable to watch lockfile") + watcher.Close() return err } go func() { @@ -39,6 +40,7 @@ func watchForLockfileContention(path string, done chan struct{}) error { klog.ErrorS(err, "inotify watcher error") } close(done) + watcher.Close() }() return nil }