From 5c6596fa8a2fa5706b3664b4cbb5eeb827ff4644 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 9 Jan 2014 17:59:31 -0800 Subject: [PATCH] Fixing issue that would prevent consul server registration --- consul/leader.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/consul/leader.go b/consul/leader.go index be7f7ac182..eb22deeb1b 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -119,9 +119,18 @@ func (s *Server) shouldHandleMember(member serf.Member) bool { func (s *Server) handleAliveMember(member serf.Member) error { state := s.fsm.State() + // Register consul service if a server + var service *structs.NodeService + if valid, _, port := isConsulServer(member); valid { + service = &structs.NodeService{ + Service: "consul", + Port: port, + } + } + // Check if the node exists found, addr := state.GetNode(member.Name) - if found && addr == member.Addr.String() { + if found && addr == member.Addr.String() && service == nil { // Check if the serfCheck is in the passing state checks := state.NodeChecks(member.Name) for _, check := range checks { @@ -132,15 +141,6 @@ func (s *Server) handleAliveMember(member serf.Member) error { } s.logger.Printf("[INFO] consul: member '%s' joined, marking health alive", member.Name) - // Register consul service if a server - var service *structs.NodeService - if valid, _, port := isConsulServer(member); valid { - service = &structs.NodeService{ - Service: "consul", - Port: port, - } - } - // Register with the catalog req := structs.RegisterRequest{ Datacenter: s.config.Datacenter,