From 1a828e39273cdd0d11920da0cf0c66650984eaa2 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Tue, 8 Dec 2015 18:31:58 -0800 Subject: [PATCH] Store WanAddress during Service/Check sync --- command/agent/local.go | 2 ++ consul/leader.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/command/agent/local.go b/command/agent/local.go index 545d11722..cb8db2775 100644 --- a/command/agent/local.go +++ b/command/agent/local.go @@ -526,6 +526,7 @@ func (l *localState) syncService(id string) error { Datacenter: l.config.Datacenter, Node: l.config.NodeName, Address: l.config.AdvertiseAddr, + WanAddress: l.config.ConsulConfig.SerfWANConfig.MemberlistConfig.AdvertiseAddr, Service: l.services[id], WriteRequest: structs.WriteRequest{Token: l.serviceToken(id)}, } @@ -583,6 +584,7 @@ func (l *localState) syncCheck(id string) error { Datacenter: l.config.Datacenter, Node: l.config.NodeName, Address: l.config.AdvertiseAddr, + WanAddress: l.config.ConsulConfig.SerfWANConfig.MemberlistConfig.AdvertiseAddr, Service: service, Check: l.checks[id], WriteRequest: structs.WriteRequest{Token: l.checkToken(id)}, diff --git a/consul/leader.go b/consul/leader.go index ff926c98b..8987120eb 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -380,6 +380,11 @@ func (s *Server) handleAliveMember(member serf.Member) error { return err } if node != nil && node.Address == member.Addr.String() { + // Check if the WAN address was updated + if node.WanAddress != member.Tags["WanAddr"] { + goto AFTER_CHECK + } + // Check if the associated service is available if service != nil { match := false