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

feat: Warn if bootstrap_expect is even number #12961

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool {
if config.Server.Enabled && config.Server.BootstrapExpect == 1 {
c.Ui.Error("WARNING: Bootstrap mode enabled! Potentially unsafe operation.")
}
if config.Server.Enabled && config.Server.BootstrapExpect%2 == 0 {
c.Ui.Error("WARNING: Number of bootstrap servers should ideally be set to an odd number.")
}
}

// ProtocolVersion has never been used. Warn if it is set as someone
Expand Down
4 changes: 4 additions & 0 deletions command/agent/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func TestCommand_Args(t *testing.T) {
[]string{"-data-dir=" + tmpDir, "-server", "-bootstrap-expect=1"},
"WARNING: Bootstrap mode enabled!",
},
{
[]string{"-data-dir=" + tmpDir, "-server", "-bootstrap-expect=2"},
"Number of bootstrap servers should ideally be set to an odd number",
},
{
[]string{"-server"},
"Must specify \"data_dir\" config option or \"data-dir\" CLI flag",
Expand Down