From d2fe0fae33f66e356cadd6096daa24d37e87df6d Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Mon, 11 Apr 2022 10:44:44 +0500 Subject: [PATCH] use the full ServerAddress as the identifier --- weed/server/raft_hashicorp.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/weed/server/raft_hashicorp.go b/weed/server/raft_hashicorp.go index 885ffdcc7..cc6578bf5 100644 --- a/weed/server/raft_hashicorp.go +++ b/weed/server/raft_hashicorp.go @@ -46,7 +46,7 @@ func (s *RaftServer) AddPeersConfiguration() (cfg raft.Configuration) { for _, peer := range s.peers { cfg.Servers = append(cfg.Servers, raft.Server{ Suffrage: raft.Voter, - ID: raft.ServerID(peer.String()), + ID: raft.ServerID(peer), Address: raft.ServerAddress(peer.ToGrpcAddress()), }) } @@ -67,12 +67,13 @@ func (s *RaftServer) UpdatePeers() { existsPeerName[string(server.ID)] = true } for _, peer := range s.peers { - if peer.String() == peerLeader || existsPeerName[peer.String()] { + peerName := string(peer) + if peerName == peerLeader || existsPeerName[peerName] { continue } - glog.V(0).Infof("adding new peer: %s", peer.String()) + glog.V(0).Infof("adding new peer: %s", peerName) s.RaftHashicorp.AddVoter( - raft.ServerID(peer.String()), raft.ServerAddress(peer.ToGrpcAddress()), 0, 0) + raft.ServerID(peerName), raft.ServerAddress(peer.ToGrpcAddress()), 0, 0) } for peer, _ := range existsPeerName { if _, found := s.peers[peer]; !found {