feat: Warn if bootstrap_expect is even number (#12961)

This commit is contained in:
Karan Sharma
2022-06-06 18:52:59 +05:30
committed by GitHub
parent eafc93902b
commit 2d95f06026
2 changed files with 7 additions and 0 deletions

View File

@@ -436,6 +436,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

View File

@@ -44,6 +44,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",