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 { func (s *Server) handleAliveMember(member serf.Member) error {
state := s.fsm.State() 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 // Check if the node exists
found, addr := state.GetNode(member.Name) 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 // Check if the serfCheck is in the passing state
checks := state.NodeChecks(member.Name) checks := state.NodeChecks(member.Name)
for _, check := range checks { 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) 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 // Register with the catalog
req := structs.RegisterRequest{ req := structs.RegisterRequest{
Datacenter: s.config.Datacenter, Datacenter: s.config.Datacenter,