mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Fixes kubelet log compression on Windows
Currently, when kubelet will try to compress the logs to a .gz file, it will attempt to rename the archive before closing its file handles, which results in an error on Windows. This addresses the issue mentioned above.
This commit is contained in:
parent
95303390ac
commit
430ada006d
@ -393,11 +393,15 @@ func (c *containerLogManager) compressLog(log string) error {
|
||||
if _, err := io.Copy(w, r); err != nil {
|
||||
return fmt.Errorf("failed to compress %q to %q: %v", log, tmpLog, err)
|
||||
}
|
||||
// The archive needs to be closed before renaming, otherwise an error will occur on Windows.
|
||||
w.Close()
|
||||
f.Close()
|
||||
compressedLog := log + compressSuffix
|
||||
if err := c.osInterface.Rename(tmpLog, compressedLog); err != nil {
|
||||
return fmt.Errorf("failed to rename %q to %q: %v", tmpLog, compressedLog, err)
|
||||
}
|
||||
// Remove old log file.
|
||||
r.Close()
|
||||
if err := c.osInterface.Remove(log); err != nil {
|
||||
return fmt.Errorf("failed to remove log %q after compress: %v", log, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user