mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
fix: No failover to next upstream when receiving SERVFAIL or REFUSED response codes(#7457) (#7458)
This commit is contained in:
@@ -51,6 +51,7 @@ type Forward struct {
|
||||
expire time.Duration
|
||||
maxConcurrent int64
|
||||
failfastUnhealthyUpstreams bool
|
||||
failoverRcodes []int
|
||||
|
||||
opts proxyPkg.Options // also here for testing
|
||||
|
||||
@@ -206,6 +207,21 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Check if we have a failover Rcode defined, check if we match on the code
|
||||
tryNext := false
|
||||
for _, failoverRcode := range f.failoverRcodes {
|
||||
// if we match, we continue to the next upstream in the list
|
||||
if failoverRcode == ret.Rcode {
|
||||
if fails < len(f.proxies) {
|
||||
tryNext = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if tryNext {
|
||||
fails++
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if we have an alternate Rcode defined, check if we match on the code
|
||||
for _, alternateRcode := range f.nextAlternateRcodes {
|
||||
if alternateRcode == ret.Rcode && f.Next != nil { // In case we do not have a Next handler, just continue normally
|
||||
|
||||
Reference in New Issue
Block a user