Fixing issue that would prevent consul server registration

This commit is contained in:
Armon Dadgar 2014-01-09 17:59:31 -08:00
parent 26134960b1
commit 79717c95bf
1 changed files with 10 additions and 10 deletions

View File

@ -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,