Merge pull request #106382 from rphillips/fix_close_log

kubelet: fix file descriptor leak in log rotations
This commit is contained in:
Kubernetes Prow Robot 2021-11-12 09:22:40 -08:00 committed by GitHub
commit 6c04f87470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -361,6 +361,7 @@ func ReadLogs(ctx context.Context, path, containerID string, opts *LogOptions, r
}
return fmt.Errorf("failed to open log file %q: %v", path, err)
}
defer newF.Close()
f.Close()
if err := watcher.Remove(f.Name()); err != nil && !os.IsNotExist(err) {
klog.ErrorS(err, "Failed to remove file watch", "path", f.Name())