Skip to content

Commit

Permalink
Merge pull request #2872 from hashicorp/b-required-quorum
Browse files Browse the repository at this point in the history
Use voter count instead of server count to calculate required quorum
  • Loading branch information
slackpad authored Apr 4, 2017
2 parents 8471360 + e6a2ef6 commit c444ac3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions consul/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ func (s *Server) updateClusterHealth() error {
// Build a current list of server healths
leader := s.raft.Leader()
var clusterHealth structs.OperatorHealthReply
healthyCount := 0
voterCount := 0
healthyCount := 0
healthyVoterCount := 0
for _, server := range servers {
health := structs.ServerHealth{
ID: string(server.ID),
Expand All @@ -336,10 +337,13 @@ func (s *Server) updateClusterHealth() error {
health.SerfStatus = serf.StatusNone
}

if health.Voter {
voterCount++
}
if health.Healthy {
healthyCount++
if health.Voter {
voterCount++
healthyVoterCount++
}
}

Expand All @@ -348,9 +352,9 @@ func (s *Server) updateClusterHealth() error {
clusterHealth.Healthy = healthyCount == len(servers)

// If we have extra healthy voters, update FailureTolerance
requiredQuorum := len(servers)/2 + 1
if voterCount > requiredQuorum {
clusterHealth.FailureTolerance = voterCount - requiredQuorum
requiredQuorum := voterCount/2 + 1
if healthyVoterCount > requiredQuorum {
clusterHealth.FailureTolerance = healthyVoterCount - requiredQuorum
}

// Heartbeat a metric for monitoring if we're the leader
Expand Down

0 comments on commit c444ac3

Please sign in to comment.