From e653583f698f4762f28535b251d0ec11910e65a8 Mon Sep 17 00:00:00 2001 From: Sarah Christoff Date: Mon, 21 Oct 2019 16:36:25 -0500 Subject: [PATCH] update calculation, remove relation to bootstrap, update test --- agent/config/builder.go | 4 ---- agent/consul/autopilot/autopilot.go | 2 +- agent/consul/autopilot_test.go | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/agent/config/builder.go b/agent/config/builder.go index 52d0c3fcb46f..06340eb455c5 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -1090,10 +1090,6 @@ func (b *Builder) Validate(rt RuntimeConfig) error { } } - //MinQuorum is set to BootstrarpExpect if available - if rt.BootstrapExpect != 0 { - rt.AutopilotMinQuorum = uint(rt.BootstrapExpect) - } // Validate the given Connect CA provider config validCAProviders := map[string]bool{ "": true, diff --git a/agent/consul/autopilot/autopilot.go b/agent/consul/autopilot/autopilot.go index 0cb609a12a08..782b333ef0ce 100644 --- a/agent/consul/autopilot/autopilot.go +++ b/agent/consul/autopilot/autopilot.go @@ -234,7 +234,7 @@ func (a *Autopilot) pruneDeadServers() error { // Only do removals if a minority of servers will be affected. peers := NumPeers(raftConfig) - if peers-removalCount > int(conf.MinQuorum) && removalCount < peers/2 { + if peers-removalCount >= int(conf.MinQuorum) && removalCount < peers/2 { for _, node := range failed { a.logger.Printf("[INFO] autopilot: Attempting removal of failed server node %q", node.Name) go serfLAN.RemoveFailedNode(node.Name) diff --git a/agent/consul/autopilot_test.go b/agent/consul/autopilot_test.go index 893f4f9629fd..4a378f6038ce 100644 --- a/agent/consul/autopilot_test.go +++ b/agent/consul/autopilot_test.go @@ -377,6 +377,7 @@ func TestAutopilot_BootstrapExpect(t *testing.T) { c.Datacenter = dc c.Bootstrap = false c.BootstrapExpect = 3 + c.AutopilotConfig.MinQuorum = 3 c.RaftConfig.ProtocolVersion = raft.ProtocolVersion(2) c.AutopilotInterval = 100 * time.Millisecond //Let us know when a server is actually gone