From 5149a75fb5ffda2f635f9fd02c8a5a997abe731c 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 f6cff9af261cf..95213c650034d 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.Errorf("unable to watch lockfile: %v", err) + watcher.Close() return err } go func() { @@ -39,6 +40,7 @@ func watchForLockfileContention(path string, done chan struct{}) error { klog.Errorf("inotify watcher error: %v", err) } close(done) + watcher.Close() }() return nil }