Do not leave raft pool if we are the only member

This commit is contained in:
Armon Dadgar 2013-12-24 12:36:50 -08:00
parent 3c7a06bb80
commit 682a986ae8
1 changed files with 7 additions and 0 deletions

View File

@ -301,6 +301,13 @@ func (s *Server) Leave() error {
// Leave the Raft cluster
if s.raft != nil {
// Check if we have other raft nodes
peers, _ := s.raftPeers.Peers()
if len(peers) <= 1 {
s.logger.Printf("[WARN] Not leaving Raft cluster, no peers")
goto AFTER_LEAVE
}
// Get the leader
leader := s.raft.Leader()
if leader == nil {