healthcheck: answer 503 when no root server gave a usable reply in the last round of DNS checks (closes #302) #304

Merged
clawbot merged 3 commits from fix/302-health-dns-unreachable into next 2026-10-18 17:24:50 +02:00
2 changed files with 19 additions and 19 deletions
Showing only changes of commit 4e39890c0a - Show all commits
+12 -12
View File
@@ -8,18 +8,18 @@ import (
"sneak.berlin/go/dnswatcher/internal/watcher"
)
// TestDNSUnreachableWhenNoRootServerReplies runs one round of checks of
// a domain and a hostname with every walk starting at real servers that
// are not root servers. At 192.0.2.1, a documentation address, nothing
// answers, as when no root server answers. Public recursive resolvers of
// four operators mark their replies recursion available, as on a network
// that intercepts DNS queries; one that gives no reply is passed over
// for the next, and if none replies, no root server answered. Either
// way every lookup failed because no root server gave a usable reply,
// so the round could not reach the DNS. TestFirstRunBaseline and
// TestDomainThatDoesNotExist check rounds in which the root servers
// gave a usable reply.
func TestDNSUnreachableWhenNoRootServerReplies(t *testing.T) {
// TestDNSUnreachableWhenNoRootServerGivesUsableReply runs one round of
// checks of a domain and a hostname with every walk starting at real
// servers that are not root servers. At 192.0.2.1, a documentation
// address, nothing answers, as when no root server answers. Public
// recursive resolvers of four operators mark their replies recursion
// available, as on a network that intercepts DNS queries; one that gives
// no reply is passed over for the next, and if none replies, no root
// server answered. Either way every lookup failed because no root server
// gave a usable reply, so the round could not reach the DNS.
// TestFirstRunBaseline and TestDomainThatDoesNotExist check rounds in
// which the root servers gave a usable reply.
func TestDNSUnreachableWhenNoRootServerGivesUsableReply(t *testing.T) {
t.Parallel()
tests := []struct {
+7 -7
View File
@@ -299,16 +299,16 @@ func (w *Watcher) runDNSChecks(ctx context.Context) {
}
if ctx.Err() == nil {
w.dnsUnreachable.Store(noRootServerReplied(errs))
w.dnsUnreachable.Store(noRootServerGaveUsableReply(errs))
}
}
// noRootServerReplied reports whether errs, the errors of the lookups in
// a round of DNS checks, nil for a lookup that succeeded, show that
// every lookup failed because no root server gave a usable reply: each
// is ErrNoRootServerAnswered or ErrIntercepted. A round with no lookups
// shows nothing.
func noRootServerReplied(errs []error) bool {
// noRootServerGaveUsableReply reports whether errs, the errors of the
// lookups in a round of DNS checks, nil for a lookup that succeeded,
// show that every lookup failed because no root server gave a usable
// reply: each is ErrNoRootServerAnswered or ErrIntercepted. A round with
// no lookups shows nothing.
func noRootServerGaveUsableReply(errs []error) bool {
for _, err := range errs {
if !errors.Is(err, resolver.ErrNoRootServerAnswered) &&
!errors.Is(err, resolver.ErrIntercepted) {