diff --git a/agent/dns.go b/agent/dns.go index 18d7092935..0114ac425c 100644 --- a/agent/dns.go +++ b/agent/dns.go @@ -609,7 +609,6 @@ func (d *DNSServer) parseDatacenter(labels []string, datacenter *string) bool { var errECSNotGlobal = fmt.Errorf("ECS response is not global") var errNameNotFound = fmt.Errorf("DNS name not found") -var errQueryRefused = fmt.Errorf("query refused") // errNoAnswer is used to indicate that the response should set SOA, and the // success response code. @@ -876,12 +875,9 @@ func rCodeFromError(err error) int { case err == nil: return dns.RcodeSuccess case errors.Is(err, errNoAnswer): - // TODO: why do we return success if the answer is empty? return dns.RcodeSuccess case errors.Is(err, errECSNotGlobal): return rCodeFromError(errors.Unwrap(err)) - case errors.Is(err, errQueryRefused): - return dns.RcodeRefused case errors.Is(err, errNameNotFound): return dns.RcodeNameError case structs.IsErrNoDCPath(err) || structs.IsErrQueryNotFound(err): @@ -896,7 +892,7 @@ func (d *DNSServer) nodeLookup(cfg *dnsConfig, datacenter, node string, req, res // Only handle ANY, A, AAAA, and TXT type requests qType := req.Question[0].Qtype if qType != dns.TypeANY && qType != dns.TypeA && qType != dns.TypeAAAA && qType != dns.TypeTXT { - return errQueryRefused + return nil } // Make an RPC request diff --git a/agent/dns_test.go b/agent/dns_test.go index cd7ed4c18a..e72b9ce7cd 100644 --- a/agent/dns_test.go +++ b/agent/dns_test.go @@ -6779,17 +6779,15 @@ func TestDNS_EDNS_Truncate_AgentSource(t *testing.T) { t.Fatalf("err: %v", err) } - { - m := new(dns.Msg) - m.SetQuestion("foo.query.consul.", dns.TypeSRV) - m.SetEdns0(2048, true) - m.Compress = false + req := new(dns.Msg) + req.SetQuestion("foo.query.consul.", dns.TypeSRV) + req.SetEdns0(2048, true) + req.Compress = false - c := new(dns.Client) - r, _, err := c.Exchange(m, a.DNSAddr()) - require.NoError(t, err) - require.True(t, r.Len() < 2048) - } + c := new(dns.Client) + resp, _, err := c.Exchange(req, a.DNSAddr()) + require.NoError(t, err) + require.True(t, resp.Len() < 2048) } func TestDNS_trimUDPResponse_NoTrim(t *testing.T) {