Store WanAddress during Service/Check sync

This commit is contained in:
James Phillips 2015-12-08 18:31:58 -08:00
parent fc61143b46
commit 1a828e3927
2 changed files with 7 additions and 0 deletions

View File

@ -526,6 +526,7 @@ func (l *localState) syncService(id string) error {
Datacenter: l.config.Datacenter, Datacenter: l.config.Datacenter,
Node: l.config.NodeName, Node: l.config.NodeName,
Address: l.config.AdvertiseAddr, Address: l.config.AdvertiseAddr,
WanAddress: l.config.ConsulConfig.SerfWANConfig.MemberlistConfig.AdvertiseAddr,
Service: l.services[id], Service: l.services[id],
WriteRequest: structs.WriteRequest{Token: l.serviceToken(id)}, WriteRequest: structs.WriteRequest{Token: l.serviceToken(id)},
} }
@ -583,6 +584,7 @@ func (l *localState) syncCheck(id string) error {
Datacenter: l.config.Datacenter, Datacenter: l.config.Datacenter,
Node: l.config.NodeName, Node: l.config.NodeName,
Address: l.config.AdvertiseAddr, Address: l.config.AdvertiseAddr,
WanAddress: l.config.ConsulConfig.SerfWANConfig.MemberlistConfig.AdvertiseAddr,
Service: service, Service: service,
Check: l.checks[id], Check: l.checks[id],
WriteRequest: structs.WriteRequest{Token: l.checkToken(id)}, WriteRequest: structs.WriteRequest{Token: l.checkToken(id)},

View File

@ -380,6 +380,11 @@ func (s *Server) handleAliveMember(member serf.Member) error {
return err return err
} }
if node != nil && node.Address == member.Addr.String() { 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 // Check if the associated service is available
if service != nil { if service != nil {
match := false match := false