Use voter count instead of server count for required quorum
This commit is contained in:
parent
ed7a6526e9
commit
a7fca8d6a7
|
@ -311,8 +311,9 @@ func (s *Server) updateClusterHealth() error {
|
||||||
// Build a current list of server healths
|
// Build a current list of server healths
|
||||||
leader := s.raft.Leader()
|
leader := s.raft.Leader()
|
||||||
var clusterHealth structs.OperatorHealthReply
|
var clusterHealth structs.OperatorHealthReply
|
||||||
healthyCount := 0
|
|
||||||
voterCount := 0
|
voterCount := 0
|
||||||
|
healthyCount := 0
|
||||||
|
healthyVoterCount := 0
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
health := structs.ServerHealth{
|
health := structs.ServerHealth{
|
||||||
ID: string(server.ID),
|
ID: string(server.ID),
|
||||||
|
@ -336,10 +337,13 @@ func (s *Server) updateClusterHealth() error {
|
||||||
health.SerfStatus = serf.StatusNone
|
health.SerfStatus = serf.StatusNone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if health.Voter {
|
||||||
|
voterCount++
|
||||||
|
}
|
||||||
if health.Healthy {
|
if health.Healthy {
|
||||||
healthyCount++
|
healthyCount++
|
||||||
if health.Voter {
|
if health.Voter {
|
||||||
voterCount++
|
healthyVoterCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,9 +352,9 @@ func (s *Server) updateClusterHealth() error {
|
||||||
clusterHealth.Healthy = healthyCount == len(servers)
|
clusterHealth.Healthy = healthyCount == len(servers)
|
||||||
|
|
||||||
// If we have extra healthy voters, update FailureTolerance
|
// If we have extra healthy voters, update FailureTolerance
|
||||||
requiredQuorum := len(servers)/2 + 1
|
requiredQuorum := voterCount/2 + 1
|
||||||
if voterCount > requiredQuorum {
|
if healthyVoterCount > requiredQuorum {
|
||||||
clusterHealth.FailureTolerance = voterCount - requiredQuorum
|
clusterHealth.FailureTolerance = healthyVoterCount - requiredQuorum
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heartbeat a metric for monitoring if we're the leader
|
// Heartbeat a metric for monitoring if we're the leader
|
||||||
|
|
Loading…
Reference in a new issue