consul: Only add ourself to the peerset if we are in bootstrap mode
This commit is contained in:
parent
b31a0510eb
commit
6142460b29
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue