Skip to content

Commit

Permalink
Merge pull request #6047 from hashicorp/b-ignore-server-if-disabled
Browse files Browse the repository at this point in the history
Only warn against BootstrapExpect set in CLI flag
  • Loading branch information
Mahmood Ali committed Oct 29, 2019
2 parents 6d59938 + 92c369c commit f010fe2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ func (c *Command) readConfig() *Config {
config.PluginDir = filepath.Join(config.DataDir, "plugins")
}

if !c.isValidConfig(config) {
if !c.isValidConfig(config, cmdConfig) {
return nil
}

return config
}

func (c *Command) isValidConfig(config *Config) bool {
func (c *Command) isValidConfig(config, cmdConfig *Config) bool {

// Check that the server is running in at least one mode.
if !(config.Server.Enabled || config.Client.Enabled) {
Expand Down Expand Up @@ -361,11 +361,12 @@ func (c *Command) isValidConfig(config *Config) bool {
}

// Check the bootstrap flags
if config.Server.BootstrapExpect > 0 && !config.Server.Enabled {
if !config.Server.Enabled && cmdConfig.Server.BootstrapExpect > 0 {
// report an error if BootstrapExpect is set in CLI but server is disabled
c.Ui.Error("Bootstrap requires server mode to be enabled")
return false
}
if config.Server.BootstrapExpect == 1 {
if config.Server.Enabled && config.Server.BootstrapExpect == 1 {
c.Ui.Error("WARNING: Bootstrap mode enabled! Potentially unsafe operation.")
}

Expand Down

0 comments on commit f010fe2

Please sign in to comment.