-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent active log from being overwritten when agent starts (#11386)
- Loading branch information
Showing
6 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
agent: Fixed an issue that could cause previous log lines to be overwritten | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build darwin || freebsd || netbsd || openbsd | ||
// +build darwin freebsd netbsd openbsd | ||
|
||
package agent | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func (l *logFile) createTime(stat os.FileInfo) time.Time { | ||
stat_t := stat.Sys().(*syscall.Stat_t) | ||
createTime := stat_t.Ctimespec | ||
return time.Unix(createTime.Sec, createTime.Nsec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build dragonfly || linux || solaris | ||
// +build dragonfly linux solaris | ||
|
||
package agent | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func (l *logFile) createTime(stat os.FileInfo) time.Time { | ||
stat_t := stat.Sys().(*syscall.Stat_t) | ||
createTime := stat_t.Ctim | ||
// Sec and Nsec are int32 in 32-bit architectures. | ||
return time.Unix(int64(createTime.Sec), int64(createTime.Nsec)) //nolint:unconvert | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package agent | ||
|
||
import ( | ||
"os" | ||
"time" | ||
) | ||
|
||
func (l *logFile) createTime(stat os.FileInfo) time.Time { | ||
// Use `ModTime` as an approximation if the exact create time is not | ||
// available. | ||
// On Windows, the file create time is not updated after the active log | ||
// rotates, so use `ModTime` as an approximation as well. | ||
return stat.ModTime() | ||
} |