healthcheck: answer 503 when no root server gave a usable reply in the last round of DNS checks (closes #302) #304
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user