resolver, watcher: a record type whose query fails keeps its previous records (closes #231)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The resolver lists in FailedTypes each record type whose query to a nameserver got no usable reply (none after two tries, an error reply, a referral, or a truncated reply whose TCP retry failed), and logs it with the reason. A nameserver that answered no type has failed, as before. The watcher saves such a type in failedTypes, keeping the previous check's records, leaves it out of the comparison with other nameservers on that check, and compares the kept records with the next answer. With nothing to keep, it is also in unknownTypes and not compared until it answers. Change messages leave out what was not compared. A nameserver whose A, AAAA or CNAME query failed is no answer when following a CNAME or resolving addresses. Model: opus-5-5
This commit is contained in:
@@ -202,6 +202,42 @@ func TestCNAMEWhoseNameserversAllFailedKeepsPrevious(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCNAMEWhoseAddressQueryFailedKeepsPrevious checks a name whose
|
||||
// nameserver answered, but whose query for A, AAAA or CNAME failed with
|
||||
// nothing kept for it. That is not an answer with no address: the
|
||||
// addresses the previous check saved from following its CNAME are kept,
|
||||
// and nothing is looked up, the watcher having no resolver.
|
||||
func TestCNAMEWhoseAddressQueryFailedKeepsPrevious(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, rtype := range []string{"A", "AAAA", "CNAME"} {
|
||||
t.Run(rtype, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := watcher.NewForTest(nil, nil, nil, nil, nil, nil)
|
||||
|
||||
current := saved(map[string]*state.NameserverRecordState{
|
||||
nsA: {
|
||||
Records: map[string][]string{},
|
||||
FailedTypes: []string{rtype},
|
||||
UnknownTypes: []string{rtype},
|
||||
Status: "ok",
|
||||
},
|
||||
})
|
||||
prev := cnameState(oldIP)
|
||||
|
||||
w.ResolveCNAMEAddresses(t.Context(), host, current, prev)
|
||||
|
||||
if !slices.Equal(current.CNAMEAddresses, prev.CNAMEAddresses) {
|
||||
t.Errorf(
|
||||
"saved %v, want %v",
|
||||
current.CNAMEAddresses, prev.CNAMEAddresses,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// cnameTo builds the records of a nameserver that answered with a CNAME
|
||||
// to target and no address.
|
||||
func cnameTo(target string) map[string][]string {
|
||||
|
||||
Reference in New Issue
Block a user