defer close the rotated log open

This commit is contained in:
Ryan Phillips 2021-11-01 17:02:16 -05:00
parent 7b9f4f18fe
commit d6f9df424a

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())