Clear the backup server list when a Nomad heartbeat arives with servers

If Nomad is heartbeating during a transition from using backup servers
to Nomad servers, make Nomad the canonical source of servers and flush
the list of servers populated from Consul.
This commit is contained in:
Sean Chittenden
2016-05-27 03:49:51 -07:00
parent ca0f2d982d
commit 9998573298

View File

@@ -642,6 +642,12 @@ func (p *RpcProxy) UpdateFromNodeUpdateResponse(resp *structs.NodeUpdateResponse
p.serverListLock.Lock()
defer p.serverListLock.Unlock()
// Clear the backup server list when a heartbeat contains at least
// one server.
if len(resp.Servers) > 0 && len(p.backupServers.L) > 0 {
p.backupServers.L = make([]*ServerEndpoint, len(resp.Servers))
}
// 1) Create a map to reconcile the difference between
// m.primaryServers and resp.Servers.
type targetServer struct {