consul: Only add ourself to the peerset if we are in bootstrap mode

This commit is contained in:
Armon Dadgar 2014-02-20 16:27:14 -08:00
parent 421c4d6933
commit 5d8783148b
1 changed files with 10 additions and 8 deletions

View File

@ -220,14 +220,16 @@ func (s *Server) setupRaft() error {
// Setup the peer store
s.raftPeers = raft.NewJSONPeers(path, trans)
// Ensure local host is always included
peers, err := s.raftPeers.Peers()
if err != nil {
store.Close()
return err
}
if !raft.PeerContained(peers, trans.LocalAddr()) {
s.raftPeers.SetPeers(raft.AddUniquePeer(peers, trans.LocalAddr()))
// Ensure local host is always included if we are in bootstrap mode
if s.config.Bootstrap {
peers, err := s.raftPeers.Peers()
if err != nil {
store.Close()
return err
}
if !raft.PeerContained(peers, trans.LocalAddr()) {
s.raftPeers.SetPeers(raft.AddUniquePeer(peers, trans.LocalAddr()))
}
}
// Make sure we set the LogOutput