watcher: a hostname whose zone's nameservers all stop answering gets NS Failure (closes #284)
check / check (push) Waiting to run
check / check (push) Waiting to run
When none of the nameservers of a hostname's zone answered, the walk to them failed and the check was only logged. The walk now returns a NoAnswerError naming the nameservers of the zone it reached through a referral when none of them answers. When those are the nameservers the previous check saved for the name, each is saved as failed with the reason, so it gets an NS Failure and later an NS Recovery. A domain with no delegation of its own, whose NS lookup is that same walk, gets the same. A walk that fails before that zone, as when the host loses its network, is still only logged. Model: opus-5-5
This commit was merged in pull request #290.
This commit is contained in:
@@ -121,7 +121,9 @@ func TestFindAuthoritativeNameservers_DelegatedSubdomain(
|
||||
// delegation of its own, so the lookup returns that walk's error, about
|
||||
// www.google.com, and tries no parent name: trying google.com and com
|
||||
// would end in ErrNoNameservers, or in the error of a walk for one of
|
||||
// them.
|
||||
// them. The servers that did not answer are those the walk started at,
|
||||
// which no referral named, so the error is no NoAnswerError, as when
|
||||
// the host running dnswatcher has lost its network.
|
||||
func TestFindAuthoritativeNameservers_NoAnswer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -134,6 +136,9 @@ func TestFindAuthoritativeNameservers_NoAnswer(t *testing.T) {
|
||||
require.NotErrorIs(t, err, resolver.ErrNoNameservers)
|
||||
assert.Contains(t, err.Error(), "query www.google.com. @"+noAnswerAddress)
|
||||
assert.Empty(t, nameservers)
|
||||
|
||||
var noAnswer *resolver.NoAnswerError
|
||||
assert.NotErrorAs(t, err, &noAnswer)
|
||||
}
|
||||
|
||||
func TestFindAuthoritativeNameservers_ReturnsSorted(
|
||||
@@ -954,12 +959,34 @@ func TestFollowDelegation_NoAnswer(t *testing.T) {
|
||||
r := resolver.NewWithQueryTimeout(slog.Default(), 100*time.Millisecond)
|
||||
|
||||
nameservers, err := r.FollowDelegation(
|
||||
t.Context(), "google.com.", []string{noAnswerAddress},
|
||||
t.Context(), "google.com.", ".", nil, []string{noAnswerAddress},
|
||||
)
|
||||
require.Error(t, err)
|
||||
assert.Empty(t, nameservers)
|
||||
}
|
||||
|
||||
// TestFollowDelegation_NoAnswerAfterReferral starts the walk for
|
||||
// www.example.net at the servers of example.net as a referral names
|
||||
// them, ns1.example.net and ns2.example.net, at 192.0.2.1, where nothing
|
||||
// answers. The error is a NoAnswerError naming them, which the watcher
|
||||
// compares with the nameservers it saved for the name.
|
||||
func TestFollowDelegation_NoAnswerAfterReferral(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
r := resolver.NewWithQueryTimeout(slog.Default(), 100*time.Millisecond)
|
||||
nameservers := []string{"ns1.example.net.", "ns2.example.net."}
|
||||
|
||||
_, err := r.FollowDelegation(
|
||||
t.Context(), "www.example.net.", "example.net.", nameservers,
|
||||
[]string{noAnswerAddress},
|
||||
)
|
||||
|
||||
var noAnswer *resolver.NoAnswerError
|
||||
require.ErrorAs(t, err, &noAnswer)
|
||||
assert.Equal(t, nameservers, noAnswer.Nameservers)
|
||||
assert.Contains(t, err.Error(), "query www.example.net. @"+noAnswerAddress)
|
||||
}
|
||||
|
||||
// TestResolveNSIterative_NoDelegationOfItsOwn walks to the nameservers
|
||||
// of www.google.com as the fallback walk does. As in
|
||||
// TestLookupNS_NoDelegationOfItsOwn, the set is empty, with no error.
|
||||
|
||||
Reference in New Issue
Block a user