Skip to content

Commit ea43ed6

Browse files
authored
bdns: remove logDNSError (#8445)
This had some special casing for the "id mismatch" error we were tracking for a while. We've resolved that issue by switching to DoH and now see 0 instances of "id mismatch." However, it's still been occasionally useful to see the detailed DNS errors, so I'm keeping a simplified log line.
1 parent ab2eb93 commit ea43ed6

File tree

3 files changed

+8
-147
lines changed

3 files changed

+8
-147
lines changed

bdns/dns.go

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package bdns
33
import (
44
"context"
55
"crypto/tls"
6-
"encoding/base64"
76
"errors"
87
"fmt"
98
"io"
@@ -48,10 +47,9 @@ type impl struct {
4847
clk clock.Clock
4948
log blog.Logger
5049

51-
queryTime *prometheus.HistogramVec
52-
totalLookupTime *prometheus.HistogramVec
53-
timeoutCounter *prometheus.CounterVec
54-
idMismatchCounter *prometheus.CounterVec
50+
queryTime *prometheus.HistogramVec
51+
totalLookupTime *prometheus.HistogramVec
52+
timeoutCounter *prometheus.CounterVec
5553
}
5654

5755
var _ Client = &impl{}
@@ -118,14 +116,6 @@ func New(
118116
},
119117
[]string{"qtype", "type", "resolver", "isTLD"},
120118
)
121-
idMismatchCounter := prometheus.NewCounterVec(
122-
prometheus.CounterOpts{
123-
Name: "dns_id_mismatch",
124-
Help: "Counter of DNS ErrId errors sliced by query type and resolver",
125-
},
126-
[]string{"qtype", "resolver"},
127-
)
128-
stats.MustRegister(queryTime, totalLookupTime, timeoutCounter, idMismatchCounter)
129119
return &impl{
130120
dnsClient: client,
131121
servers: servers,
@@ -135,7 +125,6 @@ func New(
135125
queryTime: queryTime,
136126
totalLookupTime: totalLookupTime,
137127
timeoutCounter: timeoutCounter,
138-
idMismatchCounter: idMismatchCounter,
139128
log: log,
140129
}
141130
}
@@ -230,13 +219,11 @@ func (dnsClient *impl) exchangeOne(ctx context.Context, hostname string, qtype u
230219
result = dns.RcodeToString[rsp.Rcode]
231220
}
232221
if err != nil {
233-
logDNSError(dnsClient.log, chosenServer, hostname, m, rsp, err)
234-
if err == dns.ErrId {
235-
dnsClient.idMismatchCounter.With(prometheus.Labels{
236-
"qtype": qtypeStr,
237-
"resolver": chosenServerIP,
238-
}).Inc()
239-
}
222+
dnsClient.log.Infof("logDNSError chosenServer=[%s] hostname=[%s] queryType=[%s] err=[%s]",
223+
chosenServer,
224+
hostname,
225+
qtypeStr,
226+
err)
240227
}
241228
dnsClient.queryTime.With(prometheus.Labels{
242229
"qtype": qtypeStr,
@@ -469,68 +456,6 @@ func (dnsClient *impl) LookupCAA(ctx context.Context, hostname string) ([]*dns.C
469456
return CAAs, response, ResolverAddrs{resolver}, nil
470457
}
471458

472-
// logDNSError logs the provided err result from making a query for hostname to
473-
// the chosenServer. If the err is a `dns.ErrId` instance then the Base64
474-
// encoded bytes of the query (and if not-nil, the response) in wire format
475-
// is logged as well. This function is called from exchangeOne only for the case
476-
// where an error occurs querying a hostname that indicates a problem between
477-
// the VA and the chosenServer.
478-
func logDNSError(
479-
logger blog.Logger,
480-
chosenServer string,
481-
hostname string,
482-
msg, resp *dns.Msg,
483-
underlying error) {
484-
// We don't expect logDNSError to be called with a nil msg or err but
485-
// if it happens return early. We allow resp to be nil.
486-
if msg == nil || len(msg.Question) == 0 || underlying == nil {
487-
return
488-
}
489-
queryType := dns.TypeToString[msg.Question[0].Qtype]
490-
491-
// If the error indicates there was a query/response ID mismatch then we want
492-
// to log more detail.
493-
if underlying == dns.ErrId {
494-
packedMsgBytes, err := msg.Pack()
495-
if err != nil {
496-
logger.Errf("logDNSError failed to pack msg: %v", err)
497-
return
498-
}
499-
encodedMsg := base64.StdEncoding.EncodeToString(packedMsgBytes)
500-
501-
var encodedResp string
502-
var respQname string
503-
if resp != nil {
504-
packedRespBytes, err := resp.Pack()
505-
if err != nil {
506-
logger.Errf("logDNSError failed to pack resp: %v", err)
507-
return
508-
}
509-
encodedResp = base64.StdEncoding.EncodeToString(packedRespBytes)
510-
if len(resp.Answer) > 0 && resp.Answer[0].Header() != nil {
511-
respQname = resp.Answer[0].Header().Name
512-
}
513-
}
514-
515-
logger.Infof(
516-
"logDNSError ID mismatch chosenServer=[%s] hostname=[%s] respHostname=[%s] queryType=[%s] msg=[%s] resp=[%s] err=[%s]",
517-
chosenServer,
518-
hostname,
519-
respQname,
520-
queryType,
521-
encodedMsg,
522-
encodedResp,
523-
underlying)
524-
} else {
525-
// Otherwise log a general DNS error
526-
logger.Infof("logDNSError chosenServer=[%s] hostname=[%s] queryType=[%s] err=[%s]",
527-
chosenServer,
528-
hostname,
529-
queryType,
530-
underlying)
531-
}
532-
}
533-
534459
type dohExchanger struct {
535460
clk clock.Clock
536461
hc http.Client

bdns/mocks.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ func (mock *MockClient) LookupHost(_ context.Context, hostname string) ([]netip.
125125
m.SetQuestion(dns.Fqdn(hostname), dns.TypeA)
126126
m.AuthenticatedData = true
127127
m.SetEdns0(4096, false)
128-
logDNSError(mock.Log, "mock.server", hostname, m, nil, err)
129128
return []netip.Addr{}, ResolverAddrs{"MockClient"}, &Error{dns.TypeA, hostname, err, -1, nil}
130129
}
131130
if hostname == "id.mismatch" {
@@ -139,7 +138,6 @@ func (mock *MockClient) LookupHost(_ context.Context, hostname string) ([]netip.
139138
record.Hdr = dns.RR_Header{Name: dns.Fqdn(hostname), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 0}
140139
record.A = net.ParseIP("127.0.0.1")
141140
r.Answer = append(r.Answer, record)
142-
logDNSError(mock.Log, "mock.server", hostname, m, r, err)
143141
return []netip.Addr{}, ResolverAddrs{"MockClient"}, &Error{dns.TypeA, hostname, err, -1, nil}
144142
}
145143
// dual-homed host with an IPv6 and an IPv4 address

va/http_test.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package va
33
import (
44
"bytes"
55
"context"
6-
"encoding/base64"
76
"errors"
87
"fmt"
98
mrand "math/rand/v2"
@@ -12,14 +11,11 @@ import (
1211
"net/http/httptest"
1312
"net/netip"
1413
"net/url"
15-
"regexp"
1614
"strconv"
1715
"strings"
1816
"time"
1917
"unicode/utf8"
2018

21-
"github.com/miekg/dns"
22-
2319
"github.com/letsencrypt/boulder/bdns"
2420
"github.com/letsencrypt/boulder/core"
2521
berrors "github.com/letsencrypt/boulder/errors"
@@ -413,64 +409,6 @@ func TestExtractRequestTarget(t *testing.T) {
413409
}
414410
}
415411

416-
// TestHTTPValidationDNSError attempts validation for a domain name that always
417-
// generates a DNS error, and checks that a log line with the detailed error is
418-
// generated.
419-
func TestHTTPValidationDNSError(t *testing.T) {
420-
va, mockLog := setup(nil, "", nil, nil)
421-
422-
_, _, prob := va.processHTTPValidation(ctx, identifier.NewDNS("always.error"), "/.well-known/acme-challenge/whatever")
423-
test.AssertError(t, prob, "Expected validation fetch to fail")
424-
matchingLines := mockLog.GetAllMatching(`read udp: some net error`)
425-
if len(matchingLines) != 1 {
426-
t.Errorf("Didn't see expected DNS error logged. Instead, got:\n%s",
427-
strings.Join(mockLog.GetAllMatching(`.*`), "\n"))
428-
}
429-
}
430-
431-
// TestHTTPValidationDNSIdMismatchError tests that performing an HTTP-01
432-
// challenge with a domain name that always returns a DNS ID mismatch error from
433-
// the mock resolver results in valid query/response data being logged in
434-
// a format we can decode successfully.
435-
func TestHTTPValidationDNSIdMismatchError(t *testing.T) {
436-
va, mockLog := setup(nil, "", nil, nil)
437-
438-
_, _, prob := va.processHTTPValidation(ctx, identifier.NewDNS("id.mismatch"), "/.well-known/acme-challenge/whatever")
439-
test.AssertError(t, prob, "Expected validation fetch to fail")
440-
matchingLines := mockLog.GetAllMatching(`logDNSError ID mismatch`)
441-
if len(matchingLines) != 1 {
442-
t.Errorf("Didn't see expected DNS error logged. Instead, got:\n%s",
443-
strings.Join(mockLog.GetAllMatching(`.*`), "\n"))
444-
}
445-
expectedRegex := regexp.MustCompile(
446-
`INFO: logDNSError ID mismatch ` +
447-
`chosenServer=\[mock.server\] ` +
448-
`hostname=\[id\.mismatch\] ` +
449-
`respHostname=\[id\.mismatch\.\] ` +
450-
`queryType=\[A\] ` +
451-
`msg=\[([A-Za-z0-9+=/\=]+)\] ` +
452-
`resp=\[([A-Za-z0-9+=/\=]+)\] ` +
453-
`err\=\[dns: id mismatch\]`,
454-
)
455-
456-
matches := expectedRegex.FindAllStringSubmatch(matchingLines[0], -1)
457-
test.AssertEquals(t, len(matches), 1)
458-
submatches := matches[0]
459-
test.AssertEquals(t, len(submatches), 3)
460-
461-
msgBytes, err := base64.StdEncoding.DecodeString(submatches[1])
462-
test.AssertNotError(t, err, "bad base64 encoded query msg")
463-
msg := new(dns.Msg)
464-
err = msg.Unpack(msgBytes)
465-
test.AssertNotError(t, err, "bad packed query msg")
466-
467-
respBytes, err := base64.StdEncoding.DecodeString(submatches[2])
468-
test.AssertNotError(t, err, "bad base64 encoded resp msg")
469-
resp := new(dns.Msg)
470-
err = resp.Unpack(respBytes)
471-
test.AssertNotError(t, err, "bad packed response msg")
472-
}
473-
474412
func TestSetupHTTPValidation(t *testing.T) {
475413
va, _ := setup(nil, "", nil, nil)
476414

0 commit comments

Comments
 (0)