dns: refactor label by unrolling loop
This commit is contained in:
parent
c35206db07
commit
db8ad8922e
19
agent/dns.go
19
agent/dns.go
|
@ -692,22 +692,27 @@ func (d *DNSServer) serviceLookup(network, datacenter, service, tag string, req,
|
||||||
AllowStale: *d.config.AllowStale,
|
AllowStale: *d.config.AllowStale,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var out structs.IndexedCheckServiceNodes
|
var out structs.IndexedCheckServiceNodes
|
||||||
RPC:
|
|
||||||
if err := d.agent.RPC("Health.ServiceNodes", &args, &out); err != nil {
|
if err := d.agent.RPC("Health.ServiceNodes", &args, &out); err != nil {
|
||||||
d.logger.Printf("[ERR] dns: rpc error: %v", err)
|
d.logger.Printf("[ERR] dns: rpc error: %v", err)
|
||||||
resp.SetRcode(req, dns.RcodeServerFailure)
|
resp.SetRcode(req, dns.RcodeServerFailure)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that request is not too stale, redo the request
|
if args.AllowStale && out.LastContact > staleCounterThreshold {
|
||||||
if args.AllowStale {
|
metrics.IncrCounter([]string{"consul", "dns", "stale_queries"}, 1)
|
||||||
if out.LastContact > d.config.MaxStale {
|
}
|
||||||
|
|
||||||
|
// redo the request the response was too stale
|
||||||
|
if args.AllowStale && out.LastContact > d.config.MaxStale {
|
||||||
args.AllowStale = false
|
args.AllowStale = false
|
||||||
d.logger.Printf("[WARN] dns: Query results too stale, re-requesting")
|
d.logger.Printf("[WARN] dns: Query results too stale, re-requesting")
|
||||||
goto RPC
|
|
||||||
} else if out.LastContact > staleCounterThreshold {
|
if err := d.agent.RPC("Health.ServiceNodes", &args, &out); err != nil {
|
||||||
metrics.IncrCounter([]string{"consul", "dns", "stale_queries"}, 1)
|
d.logger.Printf("[ERR] dns: rpc error: %v", err)
|
||||||
|
resp.SetRcode(req, dns.RcodeServerFailure)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue