fix: default value for logfile rotation interval (#10883)

This commit is contained in:
Joshua Powers 2022-03-29 14:05:10 -07:00 committed by GitHub
parent b9151ff560
commit fba9769720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -404,7 +404,7 @@ var agentConfig = `
## The logfile will be rotated after the time interval specified. When set
## to 0 no time based rotation is performed. Logs are rotated only when
## written to, if there is no log activity rotation may be delayed.
# logfile_rotation_interval = "0d"
# logfile_rotation_interval = "0h"
## The logfile will be rotated when it becomes larger than the specified
## size. When set to 0 no size based rotation is performed.

View File

@ -41,6 +41,12 @@ func (d *Duration) UnmarshalTOML(b []byte) error {
if durStr == "" {
durStr = "0s"
}
// special case: logging interval had a default of 0d, which silently
// failed, but in order to prevent issues with default configs that had
// uncommented the option, change it from zero days to zero hours.
if durStr == "0d" {
durStr = "0h"
}
dur, err := time.ParseDuration(durStr)
if err != nil {