Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault-4279 reporting redundant/unused keys in config #14752

Merged
merged 5 commits into from Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/14752.txt
@@ -0,0 +1,3 @@
```release-note:bug
core: report unused or redundant keys in server configuration
```
22 changes: 20 additions & 2 deletions command/server.go
Expand Up @@ -428,7 +428,7 @@ func (c *ServerCommand) parseConfig() (*server.Config, []configutil.ConfigError,
}

func (c *ServerCommand) runRecoveryMode() int {
config, _, err := c.parseConfig()
config, configErrors, err := c.parseConfig()
if err != nil {
c.UI.Error(err.Error())
return 1
Expand Down Expand Up @@ -458,6 +458,11 @@ func (c *ServerCommand) runRecoveryMode() int {
JSONFormat: logFormat == logging.JSONFormat,
})

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Warn(cErr.String())
}

// Ensure logging is flushed if initialization fails
defer c.flushLog()

Expand Down Expand Up @@ -1071,7 +1076,7 @@ func (c *ServerCommand) Run(args []string) int {
config.Listeners[0].Telemetry.UnauthenticatedMetricsAccess = true
}

parsedConfig, _, err := c.parseConfig()
parsedConfig, configErrors, err := c.parseConfig()
if err != nil {
c.UI.Error(err.Error())
return 1
Expand Down Expand Up @@ -1116,6 +1121,11 @@ func (c *ServerCommand) Run(args []string) int {
})
}

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Warn(cErr.String())
}

// Ensure logging is flushed if initialization fails
defer c.flushLog()

Expand Down Expand Up @@ -1539,13 +1549,16 @@ func (c *ServerCommand) Run(args []string) int {
// Check for new log level
var config *server.Config
var level hclog.Level
var configErrors []configutil.ConfigError
for _, path := range c.flagConfigs {
current, err := server.LoadConfig(path)
if err != nil {
c.logger.Error("could not reload config", "path", path, "error", err)
goto RUNRELOADFUNCS
}

configErrors = append(configErrors, current.Validate(path)...)

if config == nil {
config = current
} else {
Expand All @@ -1559,6 +1572,11 @@ func (c *ServerCommand) Run(args []string) int {
goto RUNRELOADFUNCS
}

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Warn(cErr.String())
}

core.SetConfig(config)

// reloading custom response headers to make sure we have
Expand Down