VAULT-12264: Fix log rotation params which require an integer (#18666)

* integer values for some log flags
* Adjusted `log_flags` to expect `int` for max files and max bytes
* Updated `server` and `agent`
 Renamed updateConfig (and updateLogConfig)
* Added int log params to test
* Adjust config/params so we can identify when they're not present
* Removed pointer confusion
This commit is contained in:
Peter Wilson
2023-01-11 20:04:57 +00:00
committed by GitHub
parent 49da2544ce
commit 8abcde7cbb
9 changed files with 157 additions and 126 deletions

View File

@@ -433,7 +433,7 @@ func (c *ServerCommand) runRecoveryMode() int {
}
// Update the 'log' related aspects of shared config based on config/env var/cli
c.Flags().updateLogConfig(config.SharedConfig)
c.Flags().applyLogConfigOverrides(config.SharedConfig)
l, err := c.configureLogging(config)
if err != nil {
c.UI.Error(err.Error())
@@ -1039,7 +1039,7 @@ func (c *ServerCommand) Run(args []string) int {
return 1
}
f.updateLogConfig(config.SharedConfig)
f.applyLogConfigOverrides(config.SharedConfig)
// Set 'trace' log level for the following 'dev' clusters
if c.flagDevThreeNode || c.flagDevFourCluster {
@@ -1696,24 +1696,14 @@ func (c *ServerCommand) configureLogging(config *server.Config) (hclog.Intercept
return nil, err
}
logRotateBytes, err := parseutil.ParseInt(config.LogRotateBytes)
if err != nil {
return nil, err
}
logRotateMaxFiles, err := parseutil.ParseInt(config.LogRotateMaxFiles)
if err != nil {
return nil, err
}
logCfg := &loghelper.LogConfig{
Name: "vault",
LogLevel: logLevel,
LogFormat: logFormat,
LogFilePath: config.LogFile,
LogRotateDuration: logRotateDuration,
LogRotateBytes: int(logRotateBytes),
LogRotateMaxFiles: int(logRotateMaxFiles),
LogRotateBytes: config.LogRotateBytes,
LogRotateMaxFiles: config.LogRotateMaxFiles,
}
return loghelper.Setup(logCfg, c.logWriter)