From 031f1874d0872bcb9f8112125637734496114a3b Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 6 Sep 2017 13:07:42 -0700 Subject: [PATCH] Pulls down some code for the check loop. --- agent/consul/leader.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/agent/consul/leader.go b/agent/consul/leader.go index 5c1a7ea4a..2ad4aea82 100644 --- a/agent/consul/leader.go +++ b/agent/consul/leader.go @@ -638,13 +638,6 @@ func (s *Server) joinConsulServer(m serf.Member, parts *metadata.Server) error { } } - addr := (&net.TCPAddr{IP: m.Addr, Port: parts.Port}).String() - - minRaftProtocol, err := ServerMinRaftProtocol(s.serfLAN.Members()) - if err != nil { - return err - } - // Processing ourselves could result in trying to remove ourselves to // fix up our address, which would make us step down. This is only // safe to attempt if there are multiple servers available. @@ -664,6 +657,11 @@ func (s *Server) joinConsulServer(m serf.Member, parts *metadata.Server) error { // but we want to avoid doing that if possible to prevent useless Raft // log entries. If the address is the same but the ID changed, remove the // old server before adding the new one. + addr := (&net.TCPAddr{IP: m.Addr, Port: parts.Port}).String() + minRaftProtocol, err := ServerMinRaftProtocol(s.serfLAN.Members()) + if err != nil { + return err + } for _, server := range configFuture.Configuration().Servers { // No-op if the raft version is too low if server.Address == raft.ServerAddress(addr) && (minRaftProtocol < 2 || parts.RaftVersion < 3) {