Skip to content

Commit 6a8bec3

Browse files
authored
Distinguish cancellation from timeout in DNS. (letsencrypt#5385)
Under normal circumstances, I believe we should never have cause to return a cancellation-related error to the user. This change should distinguish that case in the logs so we can look for it. If it turns out we do sometimes return cancellation-related errors to the user, we should do further digging and figure out why. Related letsencrypt#5346
1 parent 6cd59b7 commit 6a8bec3

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

bdns/dns_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ func TestRetry(t *testing.T) {
630630
cancel()
631631
_, err := dr.LookupTXT(ctx, "example.com")
632632
if err == nil ||
633-
err.Error() != "DNS problem: query timed out looking up TXT for example.com" {
633+
err.Error() != "DNS problem: query timed out (and was canceled) looking up TXT for example.com" {
634634
t.Errorf("expected %s, got %s", context.Canceled, err)
635635
}
636636

bdns/problem.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ func (d Error) Error() string {
3232
}
3333
// Note: we check d.underlying here even though `Timeout()` does this because the call to `netErr.Timeout()` above only
3434
// happens for `*net.OpError` underlying types!
35-
} else if d.underlying == context.Canceled || d.underlying == context.DeadlineExceeded {
35+
} else if d.underlying == context.DeadlineExceeded {
3636
detail = detailDNSTimeout
37+
} else if d.underlying == context.Canceled {
38+
detail = detailCanceled
3739
} else {
3840
detail = detailServerFailure
3941
}
@@ -60,6 +62,7 @@ func (d Error) Timeout() bool {
6062
}
6163

6264
const detailDNSTimeout = "query timed out"
65+
const detailCanceled = "query timed out (and was canceled)"
6366
const detailDNSNetFailure = "networking error"
6467
const detailServerFailure = "server failure at resolver"
6568

bdns/problem_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestError(t *testing.T) {
2828
"DNS problem: query timed out looking up TXT for hostname",
2929
}, {
3030
&Error{dns.TypeTXT, "hostname", context.Canceled, -1},
31-
"DNS problem: query timed out looking up TXT for hostname",
31+
"DNS problem: query timed out (and was canceled) looking up TXT for hostname",
3232
}, {
3333
&Error{dns.TypeCAA, "hostname", nil, dns.RcodeServerFailure},
3434
"DNS problem: SERVFAIL looking up CAA for hostname - the domain's nameservers may be malfunctioning",

0 commit comments

Comments
 (0)