Remove stale raft servers differently depending on minRaftVersion

This commit is contained in:
Kyle Havlovitz 2017-03-29 13:38:40 -07:00
parent 0cc024399d
commit e74e83fc6c
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
1 changed files with 16 additions and 2 deletions

View File

@ -123,9 +123,23 @@ func (s *Server) pruneDeadServers() error {
s.logger.Printf("[INFO] consul: Attempting removal of failed server: %v", server)
go s.serfLAN.RemoveFailedNode(server)
}
minRaftProtocol, err := ServerMinRaftProtocol(s.serfLAN.Members())
if err != nil {
return err
}
for _, raftServer := range staleRaftServers {
s.logger.Printf("[INFO] consul: Attempting removal of stale raft server : %v", raftServer.ID)
s.raft.RemoveServer(raftServer.ID, 0, 0)
var future raft.Future
if minRaftProtocol >= 2 {
s.logger.Printf("[INFO] consul: Attempting removal of stale raft server : %v", raftServer.ID)
future = s.raft.RemoveServer(raftServer.ID, 0, 0)
} else {
s.logger.Printf("[INFO] consul: Attempting removal of stale raft server : %v", raftServer.ID)
future = s.raft.RemovePeer(raftServer.Address)
}
if err := future.Error(); err != nil {
return err
}
}
} else {
s.logger.Printf("[DEBUG] consul: Failed to remove dead servers: too many dead servers: %d/%d", removalCount, peers)