DNS: fix agent returning SERVFAIL where NXDOMAIN should be returned

pull/8218/head
Yury Evtikhov 2020-06-30 23:03:31 +01:00
parent 3b4ddaaab5
commit 8d18422f19
2 changed files with 5 additions and 1 deletions

View File

@ -829,7 +829,7 @@ func (d *DNSServer) computeRCode(err error) int {
return dns.RcodeSuccess
}
dErr := err.Error()
if dErr == structs.ErrNoDCPath.Error() || dErr == consul.ErrQueryNotFound.Error() {
if structs.IsErrNoDCPath(err) || dErr == consul.ErrQueryNotFound.Error() {
return dns.RcodeNameError
}
return dns.RcodeServerFailure

View File

@ -26,6 +26,10 @@ var (
ErrDCNotAvailable = errors.New(errDCNotAvailable)
)
func IsErrNoDCPath(err error) bool {
return err != nil && strings.Contains(err.Error(), errNoDCPath)
}
func IsErrNoLeader(err error) bool {
return err != nil && strings.Contains(err.Error(), errNoLeader)
}