Warn when attempting to bootstrap an even number of nodes (#3158)

* Warn when attempting to bootstrap an even number of nodes.  Addresses #1282
* add more detailed warning for two server case
This commit is contained in:
Jared Wasinger 2017-06-21 14:36:55 -08:00 committed by James Phillips
parent 99f93cd4e7
commit 3cdde3c7ca
1 changed files with 9 additions and 0 deletions

View File

@ -411,6 +411,15 @@ func (cmd *AgentCommand) readConfig() *agent.Config {
cmd.UI.Error(fmt.Sprintf("WARNING: Expect Mode enabled, expecting %d servers", cfg.BootstrapExpect))
}
// Warn if we are expecting an even number of servers
if cfg.BootstrapExpect != 0 && cfg.BootstrapExpect%2 == 0 {
if cfg.BootstrapExpect == 2 {
cmd.UI.Error("WARNING: A cluster with 2 servers will provide no failure tolerance. See https://www.consul.io/docs/internals/consensus.html#deployment-table")
} else {
cmd.UI.Error("WARNING: A cluster with an even number of servers does not achieve optimum fault tolerance. See https://www.consul.io/docs/internals/consensus.html#deployment-table")
}
}
// Warn if we are in bootstrap mode
if cfg.Bootstrap {
cmd.UI.Error("WARNING: Bootstrap mode enabled! Do not enable unless necessary")