domains: last-round checklist for fresh DNS stamping (#724)
1. NODATA never sends a new name to the cache. An authoritative NODATA for A counts only with the verified zone's SOA in the authority section; the same server is then asked for AAAA. Addresses are classified as usual; NODATA for both stamps "" with no cached query. An empty reply without that SOA is a fresh failure. 2. The on-path nameserver skip applies to new names only. A published name's look (ResolveUpgrade) may ask the cache for any nameserver host, so a zone served only by a host on the name's path stays reachable. 3. The two-strike map never evicts a pending first strike. A taken second strike makes room; full of pending strikes, a new failure counts as the second strike. 4. ResolveUpgrade asks the nearest zone first, with the whole Timeout, then walks top-down. The nearest look leaves the registrable domain to the walk and never asks about the TLD. 5. dnsVerdicts decides each hostname once per pass and applies the verdict to every row carrying it. 6. At most four nameserver hosts per zone go to the cached LookupHost. 7. Fixtures: truncated reply, referral naming two zones, oldest-check ordering. 8. Comments match the code. Census overlay re-proposed.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
9 files changed,
+790
−139
docs/superpowers/notes/census-proposal-no-negative-prime-724.md+2 −2internal/domains/export_test.go+15 −0internal/domains/freshdns.go+197 −70internal/domains/freshdns_stamp_test.go+163 −16internal/domains/freshdns_test.go+334 −8internal/domains/reconcile.go+66 −32internal/host/agent.go+4 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv+8 −8
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-no-negative-prime-724.md b/docs/superpowers/notes/census-proposal-no-negative-prime-724.md| index f3668ced0..957be7cc8 100644 |
| --- a/docs/superpowers/notes/census-proposal-no-negative-prime-724.md |
| +++ b/docs/superpowers/notes/census-proposal-no-negative-prime-724.md |
| @@ -4,7 +4,7 @@ Ruling `census-ruling-no-negative-prime-724`. The independent reviewer approves |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| -| `internal/host/agent.go` `domainsTickConfig` | body | unchanged (2) | builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: same lookup plus a nearest-zone fallback through the cached NS set, used only for names already "pointing"), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; reads nothing new, no file, path, env var or command input added (#724) | |
| +| `internal/host/agent.go` `domainsTickConfig` | body | unchanged (2) | builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: for names already "pointing" only, asks the name's nearest zone through the cached NS set first and then the same top-down walk), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; comment updated to say which cached lookups each path makes; reads nothing new, no file, path, env var or command input added (#724) | |
| Envelopes re-pinned: `internal/domains`, `internal/host`. |
| @@ -20,6 +20,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - quiet `internal/domains/freshdns.go:FreshResolver.exchange`: reads nothing now; retired while it reads nothing (or its row keeps no sites) |
| - reads `internal/domains/reconcile.go:StampHealth`: -registry:Alias, +registry:DNSCheckedAt ×2, +registry:DNSStatus ×2, -registry:Host, -whole:Route, -whole:RouteAlias; keeps legacy, task accepted-legacy |
| -Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `70bb4d8af6dc72d82a629d1c079acf6716a32e3fef5d7ae2b1f2c761b99c614e`. |
| +Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `9d87c4c63726a6f840f22fe624edd90e1071d06d0af7ab87d895ecf64bf6551e`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/domains/export_test.go b/internal/domains/export_test.go| index 56f8150fa..6564a249f 100644 |
| --- a/internal/domains/export_test.go |
| +++ b/internal/domains/export_test.go |
| @@ -36,3 +36,18 @@ func SetFreshPassTime(d time.Duration) (restore func()) { |
| freshPassTime = d |
| return func() { freshPassTime = old } |
| } |
| + |
| +// FreshStrikeState is r's two-strike entry for name: 0 none, 1 a pending |
| +// first strike, 2 a second strike taken. |
| +func FreshStrikeState(r *FreshResolver, name string) int { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + return r.struck[name] |
| +} |
| + |
| +// FreshMaxBackoff and FreshMaxNSHosts are the resolver's map and |
| +// nameserver-host bounds. |
| +const ( |
| + FreshMaxBackoff = freshMaxBackoff |
| + FreshMaxNSHosts = freshMaxNSHosts |
| +) |
diff --git a/internal/domains/freshdns.go b/internal/domains/freshdns.go| index ecd8f179e..570d9e700 100644 |
| --- a/internal/domains/freshdns.go |
| +++ b/internal/domains/freshdns.go |
| @@ -31,9 +31,10 @@ import ( |
| // The cached resolver is still used, only for names that exist whatever |
| // the customer has done yet: the registrable domain's NS set (LookupNS), |
| // nameserver host addresses and a CNAME target outside the zone (in |
| -// practice the deployment's own edge name) (LookupHost). It is never asked |
| -// about the name or any label between it and the registrable domain; see |
| -// resolve. |
| +// practice the deployment's own edge name) (LookupHost). For a new name |
| +// (Resolve) it is never asked about the name or any label between it and |
| +// the registrable domain; see resolve. A published name (ResolveUpgrade) |
| +// exists, so that look may ask it about those too. |
| // |
| // The nameservers are named by tenant DNS, so their addresses are tenant |
| // input: every one passes publicNameserver before a socket is opened, and |
| @@ -65,9 +66,17 @@ type FreshResolver struct { |
| mu sync.Mutex |
| failedAt map[string]time.Time |
| - struck map[string]bool // names whose last fresh-first look failed once; see Strike |
| + struck map[string]int // strikePending or strikeTaken, by name; see Strike |
| } |
| +// A name's state in the two-strike map: its fresh-first look has failed |
| +// once and the second attempt is still owed (strikePending), or it has |
| +// failed twice in a row and taken the cached look (strikeTaken). |
| +const ( |
| + strikePending = 1 |
| + strikeTaken = 2 |
| +) |
| + |
| // errNoAuthority is a fresh lookup that got no usable authoritative answer. |
| var errNoAuthority = errors.New("fresh dns: no authoritative answer") |
| @@ -75,15 +84,19 @@ var errNoAuthority = errors.New("fresh dns: no authoritative answer") |
| // sent, so section 4 does not count it against its per-pass budget. |
| var errBackingOff = errors.New("fresh dns: backing off") |
| -// errNoData is an authoritative "the name exists but has no A record" (an |
| -// AAAA-only name, say). It is definitive, so it never enters the backoff, |
| -// but it is not "no such name": section 4 then gives the name the cached |
| -// look, which sees every address family and primes nothing for a name that |
| -// exists. |
| -var errNoData = errors.New("fresh dns: name exists with no A record") |
| +// errNoData is an authoritative "the name exists but has no address |
| +// record": NODATA for A and then for AAAA, each from the verified server |
| +// with the zone's SOA in the authority section (noData). A TXT record at |
| +// the name, a child such as _acme-challenge making it an empty |
| +// non-terminal, or a zone that denies with NODATA instead of "no such name" |
| +// all look like this before the customer adds the record. It is definitive, |
| +// so it never enters the backoff, and section 4 stamps it "" like "no such |
| +// name" without asking the cache: a cached query would plant a per-type |
| +// negative entry for the SOA minimum (RFC 2308), which is #724 again. |
| +var errNoData = errors.New("fresh dns: name exists with no address record") |
| // definitive reports a fresh result that settles the question: addresses, |
| -// "no such name", or "exists with no A record". |
| +// "no such name", or "exists with no address record". |
| func definitive(err error) bool { |
| return err == nil || isNotFound(err) || errors.Is(err, errNoData) |
| } |
| @@ -94,13 +107,18 @@ const ( |
| freshMaxServers = 2 |
| // freshMaxZones bounds the referrals followed below the registrable |
| // domain: up to four zones in all. Deeper delegation fails the |
| - // top-down walk; a published name's upgrade look then falls back to |
| - // its nearest zone (ResolveUpgrade), a new name to the rules in |
| + // top-down walk. A published name's upgrade look has asked its nearest |
| + // zone before that (ResolveUpgrade); a new name falls to the rules in |
| // section 4. |
| freshMaxZones = 3 |
| // freshMaxCNAMEs bounds a CNAME chain inside one reply. |
| freshMaxCNAMEs = 8 |
| - // freshMaxBackoff caps the failure map; past it the oldest go first. |
| + // freshMaxNSHosts bounds the nameserver hosts looked up through the |
| + // cache per zone, so a zone listing dozens of hosts cannot spend the |
| + // Timeout on cached lookups. |
| + freshMaxNSHosts = 4 |
| + // freshMaxBackoff caps the failure map (past it the oldest go first) |
| + // and the strike map (see Strike for what goes first there). |
| freshMaxBackoff = 4096 |
| ) |
| @@ -125,18 +143,23 @@ func freshPublicName(name string) bool { |
| // Resolve returns host's addresses as its zone's nameservers give them now, |
| // found top-down from the registrable domain (resolve). An authoritative |
| // "no such name" is a *net.DNSError with IsNotFound, the same shape the |
| -// cached resolver gives, so callers classify both alike; a name with no A |
| -// record is errNoData. |
| +// cached resolver gives, so callers classify both alike; a name with no |
| +// address record of either family is errNoData. |
| func (r *FreshResolver) Resolve(host string) ([]string, error) { |
| return r.lookup(host, false) |
| } |
| -// ResolveUpgrade is Resolve for a name that is already published, so |
| -// exists: when the top-down walk gives no definitive answer (a delegation |
| -// deeper than freshMaxZones, say) it falls back to the name's nearest zone |
| -// through the cached NS set (nearest), as #724's first fix did. Section 4 |
| -// uses it ONLY for names whose previous stamp is "pointing"; a new name |
| -// must never take it, since it asks the cache about the name's own levels. |
| +// ResolveUpgrade is the fresh look for a name that is already published, |
| +// so exists. It asks the name's nearest zone FIRST, through the cached NS |
| +// set (nearest), and walks top-down from the registrable domain only when |
| +// that gives no definitive answer. Nearest-first because it is the lookup |
| +// main did, so it succeeds wherever main's did, with the whole Timeout to |
| +// do it in: run second, a deep delegation with slow servers left it no time |
| +// and the name backed off for the whole Backoff. Priming is no concern for |
| +// a name that exists, so on this path the cache may also be asked for any |
| +// nameserver host's address (serverAddrs). Section 4 uses it ONLY for names |
| +// whose previous stamp is "pointing"; a new name must never take it, since |
| +// it asks the cache about the name's own levels. |
| func (r *FreshResolver) ResolveUpgrade(host string) ([]string, error) { |
| return r.lookup(host, true) |
| } |
| @@ -173,9 +196,15 @@ func (r *FreshResolver) lookup(host string, near bool) ([]string, error) { |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), timeout) |
| defer cancel() |
| - ips, err := r.resolve(ctx, name) |
| - if near && !definitive(err) && ctx.Err() == nil { |
| + var ips []string |
| + var err error |
| + if near { |
| ips, err = r.nearest(ctx, name) |
| + if !definitive(err) && ctx.Err() == nil { |
| + ips, err = r.resolve(ctx, name, true) |
| + } |
| + } else { |
| + ips, err = r.resolve(ctx, name, false) |
| } |
| if definitive(err) { |
| @@ -222,23 +251,39 @@ func (r *FreshResolver) Forget(host string) { |
| // false (section 4 then asks nobody else). The second in a row reports true |
| // and keeps the backoff (section 4 then takes the cached look). A |
| // definitive fresh answer, or Forget, resets the count. |
| +// |
| +// The map holds at most freshMaxBackoff names. A pending first strike is |
| +// never evicted before its second attempt: forgetting it would hold the |
| +// name a second time and defer its cached look again. When the map is |
| +// full, a name that has already taken its second strike makes room (the |
| +// worst it loses is one held pass after its backoff); when every entry is |
| +// still pending, the new failure is not recorded and counts as the second |
| +// strike, so the name takes the cached look now instead of being held. |
| func (r *FreshResolver) Strike(host string) (second bool) { |
| name := strings.ToLower(strings.TrimSuffix(host, ".")) |
| r.mu.Lock() |
| defer r.mu.Unlock() |
| - if r.struck[name] { |
| + if r.struck[name] != 0 { |
| + r.struck[name] = strikeTaken |
| return true |
| } |
| if r.struck == nil { |
| - r.struck = map[string]bool{} |
| + r.struck = map[string]int{} |
| } |
| if len(r.struck) >= freshMaxBackoff { |
| - for n := range r.struck { |
| - delete(r.struck, n) |
| - break |
| + taken := "" |
| + for n, s := range r.struck { |
| + if s == strikeTaken { |
| + taken = n |
| + break |
| + } |
| + } |
| + if taken == "" { |
| + return true |
| } |
| + delete(r.struck, taken) |
| } |
| - r.struck[name] = true |
| + r.struck[name] = strikePending |
| delete(r.failedAt, name) |
| return false |
| } |
| @@ -293,8 +338,9 @@ func registrableDomain(name string) (string, bool) { |
| // 2. Each of up to freshMaxServers public addresses of the zone's servers |
| // is verified to hold zone (verifyZone: an authoritative SOA owned by |
| // exactly zone) and then asked for name (ask). |
| -// 3. A definitive answer (addresses, or an authoritative not-found) ends |
| -// the lookup. A REFERRAL (no authority, NS records whose owner is |
| +// 3. A definitive answer (addresses, an authoritative not-found, or an |
| +// authoritative NODATA for A and AAAA carrying zone's SOA) ends the |
| +// lookup. A REFERRAL (no authority, NS records whose owner is |
| // strictly below zone and at or above name) is followed: the owner |
| // becomes zone, its servers come from the referral (glue only for |
| // nameservers inside the child zone, the cached LookupHost for the |
| @@ -312,22 +358,26 @@ func registrableDomain(name string) (string, bool) { |
| // exactly that negative entry, and the cert issuer reading the same caches |
| // would wait it out. Discovering the zone from authoritative servers |
| // needs no such query. The remaining ways a name gets a cached query are |
| -// outside this function: section 4's cached fallback after a fresh failure |
| -// and for names past the per-pass budget. |
| +// outside this function: section 4's cached look after a second fresh |
| +// failure in a row and for names past the per-pass budget. |
| +// |
| +// upgrade is ResolveUpgrade's walk for a published name: the same walk, |
| +// except that serverAddrs may ask the cache for any nameserver host. |
| // |
| // Cost, worst case: 1 + freshMaxZones zones, each up to freshMaxServers |
| -// servers, each an SOA and an A exchange: 16 authoritative exchanges, all |
| -// inside Timeout (each also inside AttemptTimeout). Cached: one LookupNS, |
| -// LookupHost for nameserver hosts until freshMaxServers IPv4 addresses are |
| -// found per zone, and at most one LookupHost for an out-of-zone CNAME |
| -// target. |
| +// servers, each an SOA and an A exchange, plus one AAAA exchange after a |
| +// NODATA: 17 authoritative exchanges, all inside Timeout (each also inside |
| +// AttemptTimeout). Cached: one LookupNS, LookupHost for at most |
| +// freshMaxNSHosts nameserver hosts per zone (fewer once freshMaxServers |
| +// IPv4 addresses are found), and at most one LookupHost for an out-of-zone |
| +// CNAME target. |
| // |
| // Verification is what makes a referral or an NS set safe to follow: a |
| // server only answers once it has shown, with authority, an SOA owned by |
| // exactly the zone it was found for, so a lame or hostile server for some |
| // other zone cannot supply the answer, and the in-zone test on a CNAME |
| // target is tied to the zone that really holds the name. |
| -func (r *FreshResolver) resolve(ctx context.Context, name string) ([]string, error) { |
| +func (r *FreshResolver) resolve(ctx context.Context, name string, upgrade bool) ([]string, error) { |
| zone, ok := registrableDomain(name) |
| if !ok { |
| return nil, fmt.Errorf("%w: %s is a public suffix", errNoAuthority, name) |
| @@ -341,7 +391,7 @@ func (r *FreshResolver) resolve(ctx context.Context, name string) ([]string, err |
| hosts[i] = ns.Host |
| } |
| registrable := zone |
| - servers := r.serverAddrs(ctx, name, registrable, zone, hosts, nil) |
| + servers := r.serverAddrs(ctx, name, registrable, zone, hosts, nil, upgrade) |
| for referrals := 0; ; referrals++ { |
| ips, ref, err := r.askZone(ctx, servers, name, zone) |
| if ref == nil { |
| @@ -350,28 +400,38 @@ func (r *FreshResolver) resolve(ctx context.Context, name string) ([]string, err |
| if referrals >= freshMaxZones { |
| return nil, fmt.Errorf("%w: delegation to %s is more than %d levels below the registrable domain", errNoAuthority, name, freshMaxZones) |
| } |
| - servers = r.serverAddrs(ctx, name, registrable, ref.zone, ref.hosts, ref.glue) |
| + servers = r.serverAddrs(ctx, name, registrable, ref.zone, ref.hosts, ref.glue, upgrade) |
| zone = ref.zone |
| } |
| } |
| -// nearest is ResolveUpgrade's fallback for a published name: the cached NS |
| -// set of the name's immediate parent, then of the name itself (an apex or |
| -// a delegated sub-zone, which the parent only refers to), each verified |
| -// and asked like any zone, inside the same Timeout. It may ask the cache |
| -// about the name's own levels, which is why only a name that already |
| -// exists ever comes here. |
| +// nearest is ResolveUpgrade's first look for a published name: the cached |
| +// NS set of the name's immediate parent, then of the name itself (a |
| +// delegated sub-zone, which the parent only refers to), each verified and |
| +// asked like any zone, inside the same Timeout. The registrable domain is |
| +// left to the top-down walk that follows, which starts there: so a name |
| +// directly under it tries only itself here, and an apex nothing at all |
| +// (its parent would be the TLD, whose servers are never asked). It may ask |
| +// the cache about the name's own levels, which is why only a name that |
| +// already exists ever comes here. |
| func (r *FreshResolver) nearest(ctx context.Context, name string) ([]string, error) { |
| - registrable, _ := registrableDomain(name) |
| + registrable, ok := registrableDomain(name) |
| var last error = fmt.Errorf("%w: no zone near %s", errNoAuthority, name) |
| - for _, zone := range []string{name[strings.Index(name, ".")+1:], name} { |
| + if !ok || name == registrable { |
| + return nil, last |
| + } |
| + zones := []string{name} |
| + if parent := name[strings.Index(name, ".")+1:]; parent != registrable { |
| + zones = []string{parent, name} |
| + } |
| + for _, zone := range zones { |
| nss, err := r.LookupNS(ctx, zone) |
| if err == nil && len(nss) > 0 { |
| hosts := make([]string, len(nss)) |
| for i, ns := range nss { |
| hosts[i] = ns.Host |
| } |
| - ips, ref, err := r.askZone(ctx, r.serverAddrs(ctx, name, registrable, zone, hosts, nil), name, zone) |
| + ips, ref, err := r.askZone(ctx, r.serverAddrs(ctx, name, registrable, zone, hosts, nil, true), name, zone) |
| if ref == nil && definitive(err) { |
| return ips, err |
| } |
| @@ -417,27 +477,41 @@ type referral struct { |
| // serverAddrs resolves zone's NS hosts (in random order) and keeps up to |
| // freshMaxServers addresses that pass publicNameserver, IPv4 first: a box |
| // without a working IPv6 route would otherwise spend its attempts on |
| -// silence. For a referred zone (glue non-nil) a host inside the zone is |
| -// taken from glue only, never the cache: the cache would be asked about a |
| -// name below the registrable domain. A host that is name itself or one of |
| -// its levels below registrable (a stale NS entry naming eu.example.com, or |
| -// the name) is never looked up through the cache at all, at the |
| -// registrable domain or on a referral: that label may not exist, and the |
| -// lookup would plant its negative (Astra R3 on #724). Other hosts go to the |
| -// cached LookupHost. |
| -func (r *FreshResolver) serverAddrs(ctx context.Context, name, registrable, zone string, hosts []string, glue map[string][]netip.Addr) []netip.AddrPort { |
| +// silence. At most freshMaxNSHosts hosts go to the cached LookupHost. |
| +// |
| +// For a NEW name (upgrade false) two kinds of host never reach the cache. |
| +// A host inside a referred zone (glue non-nil) is taken from glue only: |
| +// the cache would be asked about a name below the registrable domain. And |
| +// a host that is name itself or one of its levels below registrable (a |
| +// stale NS entry naming eu.example.com, or the name) is not looked up at |
| +// all, at the registrable domain or on a referral: that label may not |
| +// exist, and the lookup would plant its negative (Astra R3 on #724). |
| +// |
| +// For a published name (upgrade true) neither rule applies: the name |
| +// exists, so there is nothing to prime, and a zone whose only nameserver |
| +// host sits on the name's path (example.com served by eu.example.com, for |
| +// shop.eu.example.com) must still be reachable or the name would be |
| +// unpublished. Glue is used where the referral carries it, the cache for |
| +// every other host. |
| +func (r *FreshResolver) serverAddrs(ctx context.Context, name, registrable, zone string, hosts []string, glue map[string][]netip.Addr, upgrade bool) []netip.AddrPort { |
| onPath := func(host string) bool { |
| return host == name || (strings.HasSuffix(name, "."+host) && strings.HasSuffix(host, "."+registrable)) |
| } |
| var v4, v6 []netip.AddrPort |
| + lookups := 0 |
| for _, i := range rand.Perm(len(hosts)) { |
| host := strings.ToLower(strings.TrimSuffix(hosts[i], ".")) |
| var addrs []netip.Addr |
| - if glue != nil && (host == zone || strings.HasSuffix(host, "."+zone)) { |
| + inChild := glue != nil && (host == zone || strings.HasSuffix(host, "."+zone)) |
| + if inChild && (!upgrade || len(glue[host]) > 0) { |
| addrs = glue[host] |
| - } else if onPath(host) { |
| + } else if !upgrade && onPath(host) { |
| continue |
| } else { |
| + if lookups >= freshMaxNSHosts { |
| + continue |
| + } |
| + lookups++ |
| found, err := r.LookupHost(ctx, host) |
| if err != nil { |
| continue |
| @@ -599,12 +673,14 @@ func (r *FreshResolver) verifyZone(ctx context.Context, server netip.AddrPort, z |
| } |
| // ask sends one non-recursive IN A query for name to server, which |
| -// verifyZone has shown holds zone, and reads the answer. A reply without |
| -// authority is only usable as a referral down the name's path (see |
| -// referralFrom). A CNAME chain in an authoritative reply is followed; if it |
| -// ends outside zone with no address in the reply, the target goes to the |
| -// cached LookupHost. A chain that loops, runs past freshMaxCNAMEs, or ends |
| -// inside zone with no address is not an answer. |
| +// verifyZone has shown holds zone, and reads the answer. A truncated reply |
| +// is a failure for this server. A reply without authority is only usable |
| +// as a referral down the name's path (see referralFrom). A CNAME chain in |
| +// an authoritative reply is followed; if it ends outside zone with no |
| +// address in the reply, the target goes to the cached LookupHost. A chain |
| +// that loops, runs past freshMaxCNAMEs, or ends inside zone with no address |
| +// is not an answer. A NODATA for the name itself sends one AAAA query to |
| +// the same server (see answer). |
| func (r *FreshResolver) ask(ctx context.Context, server netip.AddrPort, name, zone string) ([]string, *referral, error) { |
| reply, err := r.query(ctx, server, name, dnsmessage.TypeA) |
| if err != nil { |
| @@ -671,6 +747,52 @@ func referralFrom(reply *dnsmessage.Message, name, zone string) (*referral, erro |
| return ref, nil |
| } |
| +// noData reports whether reply, which the caller has checked carries |
| +// authority, is a NODATA from zone: success, no answer, and an IN SOA owned |
| +// by exactly zone in the authority section (RFC 2308 section 2.2). Without |
| +// that SOA an empty reply proves nothing about the name (a referral-shaped |
| +// reply, or a server answering for some other zone, looks the same), so it |
| +// is a failure, not a verdict. |
| +func noData(reply *dnsmessage.Message, zone string) bool { |
| + if reply.RCode != dnsmessage.RCodeSuccess || len(reply.Answers) != 0 { |
| + return false |
| + } |
| + for _, rr := range reply.Authorities { |
| + if _, ok := rr.Body.(*dnsmessage.SOAResource); ok && rr.Header.Class == dnsmessage.ClassINET && |
| + strings.EqualFold(rr.Header.Name.String(), zone+".") { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// answerAAAA runs after server's NODATA for name's A record: one AAAA |
| +// query to the same verified server. Addresses owned by name are the |
| +// answer (section 4 classifies them with the usual any-edge rule); a |
| +// second NODATA is errNoData; anything else is a failure. |
| +func (r *FreshResolver) answerAAAA(ctx context.Context, server netip.AddrPort, name, zone string) ([]string, error) { |
| + reply, err := r.exchange(ctx, server, name, dnsmessage.TypeAAAA) |
| + if err != nil { |
| + return nil, err |
| + } |
| + var ips []string |
| + if reply.RCode == dnsmessage.RCodeSuccess { |
| + for _, rr := range reply.Answers { |
| + if a, ok := rr.Body.(*dnsmessage.AAAAResource); ok && rr.Header.Class == dnsmessage.ClassINET && |
| + strings.EqualFold(rr.Header.Name.String(), name+".") { |
| + ips = append(ips, netip.AddrFrom16(a.AAAA).String()) |
| + } |
| + } |
| + } |
| + if len(ips) > 0 { |
| + return ips, nil |
| + } |
| + if noData(reply, zone) { |
| + return nil, fmt.Errorf("%w: %s (from %s)", errNoData, name, server) |
| + } |
| + return nil, fmt.Errorf("%w: %s gave no usable AAAA answer for %s", errNoAuthority, server, name) |
| +} |
| + |
| // answer reads an authoritative reply to name's A query from server. |
| func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, server netip.AddrPort, name, zone string) ([]string, error) { |
| fqdn := name + "." |
| @@ -714,8 +836,13 @@ func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, s |
| } |
| target := strings.TrimSuffix(current, ".") |
| if target == name { |
| - // Authoritative, the name exists, and it has no A record. |
| - return nil, fmt.Errorf("%w: %s (from %s)", errNoData, name, server) |
| + // No A record and no CNAME for the name. Only a NODATA carrying the |
| + // verified zone's SOA says the name exists without one; then the |
| + // same server is asked for AAAA. |
| + if !noData(reply, zone) { |
| + return nil, fmt.Errorf("%w: %s gave no answer and no SOA of %s for %s", errNoAuthority, server, zone, name) |
| + } |
| + return r.answerAAAA(ctx, server, name, zone) |
| } |
| if target == zone || strings.HasSuffix(target, "."+zone) { |
| // In-zone target this server gave no address for: no fallback to |
diff --git a/internal/domains/freshdns_stamp_test.go b/internal/domains/freshdns_stamp_test.go| index 553af63de..3db5119d1 100644 |
| --- a/internal/domains/freshdns_stamp_test.go |
| +++ b/internal/domains/freshdns_stamp_test.go |
| @@ -749,34 +749,158 @@ func TestStampHealthDeepDelegation(t *testing.T) { |
| }) |
| } |
| -// Astra R3 P2-2: a new name with only an AAAA record pointing at an IPv6 |
| -// edge. The fresh look says "exists, no A record"; the cached look, which |
| -// sees AAAA, decides, and the name is "pointing". |
| -func TestStampHealthAAAAOnlyName(t *testing.T) { |
| - const edge6 = "2001:db8::7" |
| - fa := startAuthority(t, "example.com", authoritative()) |
| - fresh := oneZone(fa).resolver(clock()) |
| - reg := regWithAlias(t, "shop.example.com") |
| - cfg := domains.Config{ |
| +// worldCfg is production wiring over w's resolver, with a cached resolver |
| +// that says NXDOMAIN for name and counts its queries in asked. |
| +func worldCfg(w *world, name string, asked map[string]int, edges ...string) (domains.Config, *domains.FreshResolver) { |
| + fresh := w.resolver(clock()) |
| + return domains.Config{ |
| AppsDomain: "oncarlos.test", |
| - EdgeIPs: func() []string { return []string{edgeIP, edge6} }, |
| - Resolve: func(h string) ([]string, error) { |
| - if h == "shop.example.com" { |
| - return []string{edge6}, nil |
| + EdgeIPs: func() []string { return append([]string{edgeIP}, edges...) }, |
| + Resolve: counted(func(h string) ([]string, error) { |
| + if h == name { |
| + return nxdomain(h) |
| } |
| return pointingAt(h) |
| - }, |
| + }, asked), |
| ResolveFresh: fresh.Resolve, |
| ResolveUpgrade: fresh.ResolveUpgrade, |
| FreshForget: fresh.Forget, |
| FreshStrike: fresh.Strike, |
| Now: func() time.Time { return time.Unix(5000, 0) }, |
| + }, fresh |
| +} |
| + |
| +// INVARIANT GUARD (item 1 of the last round on #724): an authoritative |
| +// NODATA never sends a new name to the cache. A name with only an AAAA |
| +// record pointing at an IPv6 edge is "pointing" from the same server's AAAA |
| +// answer; a name that exists with no address record (a TXT there before |
| +// the CNAME, an _acme-challenge child) is stamped "". Zero cached queries |
| +// for the name either way: the cache would keep a per-type negative. |
| +func TestStampHealthNoDataNeverAsksTheCache(t *testing.T) { |
| + const edge6 = "2001:db8::7" |
| + for name, tc := range map[string]struct { |
| + aaaa func(dnsmessage.Question, *dnsmessage.Message) bool |
| + want string |
| + }{ |
| + "AAAA only, pointing at an IPv6 edge": {authoritative(aaaaRecord("shop.example.com.", edge6)), "pointing"}, |
| + "AAAA only, elsewhere": {authoritative(aaaaRecord("shop.example.com.", "2001:db8::99")), "elsewhere"}, |
| + "TXT only": {nodata("example.com"), ""}, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", byType(nodata("example.com"), tc.aaaa))) |
| + asked := map[string]int{} |
| + cfg, _ := worldCfg(w, "shop.example.com", asked, edge6) |
| + reg := regWithAlias(t, "shop.example.com") |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if a := aliasRow(t, reg, "shop.example.com"); a.DNSStatus != tc.want || a.DNSCheckedAt == 0 { |
| + t.Fatalf("alias stamp = %q at %d, want %q stamped this pass", a.DNSStatus, a.DNSCheckedAt, tc.want) |
| + } |
| + if asked["shop.example.com"] != 0 { |
| + t.Fatalf("cached resolver asked about shop.example.com %d times, want 0", asked["shop.example.com"]) |
| + } |
| + noCachedBelow(t, w, "shop.example.com", "example.com") |
| + }) |
| + } |
| +} |
| + |
| +// INVARIANT GUARD (Astra P1 of the last round on #724): example.com's only |
| +// nameserver host is eu.example.com, on the path of shop.eu.example.com. |
| +// Published, the name stays "pointing" while the cache says NXDOMAIN: its |
| +// upgrade look may ask the cache for that host. As a NEW candidate the |
| +// same name still sends no cached query below the registrable domain. |
| +func TestStampHealthOnPathOnlyNameserver(t *testing.T) { |
| + const name = "shop.eu.example.com" |
| + t.Run("published", func(t *testing.T) { |
| + cfg, _ := worldCfg(onPathWorld(t), name, map[string]int{}) |
| + reg := regWithAlias(t, name) |
| + stampAlias(t, reg, name, "pointing") |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := aliasStatus(t, reg, name); got != "pointing" { |
| + t.Fatalf("published alias = %q, want pointing", got) |
| + } |
| + }) |
| + t.Run("new", func(t *testing.T) { |
| + w := onPathWorld(t) |
| + asked := map[string]int{} |
| + cfg, _ := worldCfg(w, name, asked) |
| + reg := regWithAlias(t, name) |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + noCachedBelow(t, w, name, "example.com") |
| + if asked[name] != 0 { |
| + t.Fatalf("cached resolver asked about %s %d times, want 0", name, asked[name]) |
| + } |
| + }) |
| +} |
| + |
| +// INVARIANT GUARD (strike map overflow, last round on #724): a new name's |
| +// first fresh failure is held; then the two-strike map overflows with |
| +// other names' failures; the name's second failure, on the next pass, |
| +// still takes the cached look instead of being held again. |
| +func TestStampHealthStrikeSurvivesAFullMap(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", nil)) |
| + asked := map[string]int{} |
| + cfg, fresh := worldCfg(w, "shop.example.com", asked) |
| + reg := regWithAlias(t, "shop.example.com") |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if asked["shop.example.com"] != 0 || aliasRow(t, reg, "shop.example.com").DNSCheckedAt != 0 { |
| + t.Fatal("pass A: the first fresh failure was not held") |
| + } |
| + for i := 0; i < 2*domains.FreshMaxBackoff; i++ { |
| + fresh.Strike(fmt.Sprintf("n%d.example.net", i)) |
| } |
| if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| t.Fatal(err) |
| } |
| - if got := aliasStatus(t, reg, "shop.example.com"); got != "pointing" { |
| - t.Fatalf("AAAA-only alias = %q, want pointing", got) |
| + if asked["shop.example.com"] != 1 || aliasRow(t, reg, "shop.example.com").DNSCheckedAt == 0 { |
| + t.Fatalf("pass B: cached asked %d times, want 1: the pending strike was forgotten and the name held again", asked["shop.example.com"]) |
| + } |
| +} |
| + |
| +// Fable P3 of the last round: a hostname carried by two rows (a route and |
| +// an alias) is decided once per pass. Decided twice, the second row's |
| +// fresh failure would be the second strike inside the same pass and take |
| +// the cached look the first had just held. |
| +func TestStampHealthDecidesAHostOncePerPass(t *testing.T) { |
| + const name = "shop.example.com" |
| + fa := startAuthority(t, "example.com", nil) |
| + w := oneZone(fa) |
| + asked := map[string]int{} |
| + cfg, _ := worldCfg(w, name, asked) |
| + reg := regWith(t, |
| + registry.Route{Host: "app.acct.oncarlos.test", Kind: "service", Addr: "10.0.0.1:1", Status: "ready"}, |
| + registry.Route{Host: name, Kind: "service", Addr: "10.0.0.1:2", Status: "ready"}, |
| + ) |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: name, Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if asked[name] != 0 { |
| + t.Fatalf("pass A: cached asked about %s %d times, want 0 (one held first strike)", name, asked[name]) |
| + } |
| + if rt, a := mustGet(t, reg, name), aliasRow(t, reg, name); rt.DNSCheckedAt != 0 || a.DNSCheckedAt != 0 { |
| + t.Fatalf("pass A: route checked at %d, alias at %d; want both held", rt.DNSCheckedAt, a.DNSCheckedAt) |
| + } |
| + sent := fa.queries.Load() |
| + // Pass B: the second strike. One fresh look, one cached look, and the |
| + // verdict on both rows. |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if fa.queries.Load() == sent || asked[name] != 1 { |
| + t.Fatalf("pass B: %d more fresh queries and %d cached; want a fresh retry and exactly one cached look", fa.queries.Load()-sent, asked[name]) |
| + } |
| + if rt, a := mustGet(t, reg, name), aliasRow(t, reg, name); rt.DNSCheckedAt == 0 || a.DNSCheckedAt == 0 { |
| + t.Fatalf("pass B: route checked at %d, alias at %d; want both stamped", rt.DNSCheckedAt, a.DNSCheckedAt) |
| } |
| } |
| @@ -803,6 +927,29 @@ func TestStampHealthFreshBudgetOrder(t *testing.T) { |
| } |
| } |
| }) |
| + // Distinct from never-checked-first: both names have been checked, and |
| + // the one checked longest ago gets the budget. |
| + t.Run("oldest check first", func(t *testing.T) { |
| + for trial := 0; trial < 10; trial++ { |
| + reg := regWithAlias(t, "recent.example.com") |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: "stale.example.com", Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + for alias, at := range map[string]int64{"recent.example.com": 300, "stale.example.com": 200} { |
| + if err := reg.SetAliasDNSStatus(alias, "elsewhere", at); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + var calls []string |
| + cfg := freshCfg(pointingAt, nxdomain, &calls) |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(calls) != 1 || calls[0] != "stale.example.com" { |
| + t.Fatalf("fresh lookups = %v, want [stale.example.com]", calls) |
| + } |
| + } |
| + }) |
| t.Run("backoff hits are free", func(t *testing.T) { |
| reg := regWithAlias(t, "a.example.com") |
| if err := reg.UpsertAlias(registry.RouteAlias{Alias: "b.example.com", Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil { |
diff --git a/internal/domains/freshdns_test.go b/internal/domains/freshdns_test.go| index 86d49a66f..190fa0d63 100644 |
| --- a/internal/domains/freshdns_test.go |
| +++ b/internal/domains/freshdns_test.go |
| @@ -700,10 +700,10 @@ func TestFreshResolverBoundsTheReferrals(t *testing.T) { |
| noCachedBelow(t, w, name, "example.com") |
| } |
| -// Astra R3 P1 on #724: ResolveUpgrade, for a published name only, falls |
| -// back to the name's nearest zone when the top-down walk gives no answer, |
| -// so a deep delegation main reached still resolves. |
| -func TestFreshResolverUpgradeFallsBackToTheNearestZone(t *testing.T) { |
| +// Astra R3 P1 on #724: ResolveUpgrade, for a published name only, asks the |
| +// name's nearest zone, so a delegation deeper than the top-down walk |
| +// follows, which main reached, still resolves. |
| +func TestFreshResolverUpgradeReachesADeepDelegation(t *testing.T) { |
| w, last := deepWorld(t) |
| ips, err := w.resolver(clock()).ResolveUpgrade(deepName) |
| if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| @@ -714,15 +714,61 @@ func TestFreshResolverUpgradeFallsBackToTheNearestZone(t *testing.T) { |
| } |
| } |
| -// Astra R3 P2-2: an authoritative "exists, no A record" (AAAA only) is |
| -// not "no such name": it is errNoData, and it does not back off. |
| +// nodata answers every non-SOA query as zone's server does for a name that |
| +// exists with no record of the type asked: authority, no answer, and |
| +// zone's SOA in the authority section. |
| +func nodata(zone string) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| + return func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authoritative = true |
| + r.Authorities = []dnsmessage.Resource{soaRecord(zone)} |
| + return true |
| + } |
| +} |
| + |
| +// byType answers A queries with a and AAAA queries with aaaa. |
| +func byType(a, aaaa func(dnsmessage.Question, *dnsmessage.Message) bool) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| + return func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + if q.Type == dnsmessage.TypeAAAA { |
| + return aaaa(q, r) |
| + } |
| + return a(q, r) |
| + } |
| +} |
| + |
| +func aaaaRecord(name, ip string) dnsmessage.Resource { |
| + return dnsmessage.Resource{ |
| + Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(name), Type: dnsmessage.TypeAAAA, Class: dnsmessage.ClassINET, TTL: 300}, |
| + Body: &dnsmessage.AAAAResource{AAAA: netip.MustParseAddr(ip).As16()}, |
| + } |
| +} |
| + |
| +// referralShaped is an authoritative reply with no answer and only NS |
| +// records in the authority section: empty, but no proof of NODATA. |
| +func referralShaped(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authoritative = true |
| + r.Authorities = []dnsmessage.Resource{{ |
| + Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName("example.com."), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300}, |
| + Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName("ns1.example.com.")}, |
| + }} |
| + return true |
| +} |
| + |
| +// Astra R3 P2-2 and item 1 of the last round: an authoritative "exists, no |
| +// address record" (NODATA for A, then for AAAA from the same server, each |
| +// carrying the zone's SOA) is not "no such name": it is errNoData. It does |
| +// not back off, and the cache hears nothing about the name. |
| func TestFreshResolverTellsNoDataFromNXDOMAIN(t *testing.T) { |
| - fa := startAuthority(t, "example.com", authoritative()) |
| - r := oneZone(fa).resolver(clock()) |
| + fa := startAuthority(t, "example.com", nodata("example.com")) |
| + w := oneZone(fa) |
| + r := w.resolver(clock()) |
| _, err := r.Resolve("shop.example.com") |
| if err == nil || isNotFoundErr(err) || !errors.Is(err, domains.ErrFreshNoData) { |
| t.Fatalf("Resolve error = %v, want errNoData", err) |
| } |
| + if got := fa.queries.Load(); got != 3 { |
| + t.Fatalf("authority got %d queries, want 3: SOA, A, then AAAA from the same server", got) |
| + } |
| + noCachedBelow(t, w, "shop.example.com", "example.com") |
| sent := fa.queries.Load() |
| _, _ = r.Resolve("shop.example.com") |
| if fa.queries.Load() == sent { |
| @@ -730,6 +776,286 @@ func TestFreshResolverTellsNoDataFromNXDOMAIN(t *testing.T) { |
| } |
| } |
| +// After a NODATA for A the same server's AAAA records are the answer. |
| +func TestFreshResolverReadsAAAAAfterNoData(t *testing.T) { |
| + const edge6 = "2001:db8::7" |
| + fa := startAuthority(t, "example.com", byType(nodata("example.com"), authoritative(aaaaRecord("shop.example.com.", edge6)))) |
| + w := oneZone(fa) |
| + ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| + if err != nil || len(ips) != 1 || ips[0] != edge6 { |
| + t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, edge6) |
| + } |
| + noCachedBelow(t, w, "shop.example.com", "example.com") |
| +} |
| + |
| +// An empty authoritative reply is NODATA only with the verified zone's own |
| +// SOA in its authority section. Without it, for the A or the AAAA |
| +// question, the lookup is a failure: not errNoData, not "no such name", |
| +// and it backs off. |
| +func TestFreshResolverNoDataNeedsTheZonesSOA(t *testing.T) { |
| + good := nodata("example.com") |
| + bad := map[string]func(dnsmessage.Question, *dnsmessage.Message) bool{ |
| + "missing SOA": authoritative(), |
| + "wrong-owner SOA": nodata("example.net"), |
| + "SOA of a name below the zone": nodata("shop.example.com"), |
| + "referral-shaped authoritative": referralShaped, |
| + "SOA beside an unrelated answer": func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authoritative = true |
| + r.Answers = []dnsmessage.Resource{aRecord("other.example.com.", edgeIP)} |
| + r.Authorities = []dnsmessage.Resource{soaRecord("example.com")} |
| + return true |
| + }, |
| + } |
| + for name, reply := range bad { |
| + for q, answer := range map[string]func(dnsmessage.Question, *dnsmessage.Message) bool{ |
| + "A": byType(reply, good), |
| + "AAAA": byType(good, reply), |
| + } { |
| + t.Run(name+" for "+q, func(t *testing.T) { |
| + fa := startAuthority(t, "example.com", answer) |
| + w := oneZone(fa) |
| + r := w.resolver(clock()) |
| + ips, err := r.Resolve("shop.example.com") |
| + if err == nil || errors.Is(err, domains.ErrFreshNoData) || isNotFoundErr(err) { |
| + t.Fatalf("Resolve = %v, %v; want a fresh failure", ips, err) |
| + } |
| + sent := fa.queries.Load() |
| + if _, err := r.Resolve("shop.example.com"); !errors.Is(err, domains.ErrFreshBackingOff) || fa.queries.Load() != sent { |
| + t.Fatalf("second Resolve = %v after %d more queries, want the backoff", err, fa.queries.Load()-sent) |
| + } |
| + noCachedBelow(t, w, "shop.example.com", "example.com") |
| + }) |
| + } |
| + } |
| +} |
| + |
| +// A truncated reply (TC bit) is a failure for that server, whatever it |
| +// carries: the next server's answer is the one used, and alone it is no |
| +// answer. |
| +func TestFreshResolverTruncatedReplyIsNotAnAnswer(t *testing.T) { |
| + truncated := func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authoritative, r.Truncated = true, true |
| + r.Answers = []dnsmessage.Resource{aRecord(q.Name.String(), "198.51.100.9")} |
| + return true |
| + } |
| + t.Run("next server answers", func(t *testing.T) { |
| + tc := startAuthority(t, "example.com", truncated) |
| + healthy := startAuthority(t, "example.com", authoritative(aRecord("shop.example.com.", edgeIP))) |
| + w := &world{ |
| + ns: map[string][]string{"example.com": {"ns1.example.com."}}, |
| + hosts: map[string][]string{"ns1.example.com": {"192.0.2.1", "192.0.2.2"}}, |
| + routes: map[string]*fakeAuthority{"192.0.2.1:53": tc, "192.0.2.2:53": healthy}, |
| + } |
| + ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("Resolve = %v, %v; want the second server's [%s]", ips, err, edgeIP) |
| + } |
| + if tc.queries.Load() < 2 { |
| + t.Fatal("the truncating server was never asked for the A record") |
| + } |
| + }) |
| + t.Run("alone", func(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", truncated)) |
| + ips, err := w.resolver(clock()).Resolve("shop.example.com") |
| + if err == nil || isNotFoundErr(err) || errors.Is(err, domains.ErrFreshNoData) { |
| + t.Fatalf("Resolve = %v, %v; want a fresh failure", ips, err) |
| + } |
| + }) |
| +} |
| + |
| +// A referral whose authority section names two different NS owners is |
| +// refused, even when both lie on the name's path; neither is dialled. |
| +func TestFreshResolverRefusesAReferralNamingTwoZones(t *testing.T) { |
| + child := startAuthority(t, "", authoritative(aRecord("shop.b.a.example.com.", edgeIP))) |
| + parent := startAuthority(t, "example.com", func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + for _, owner := range []string{"a.example.com.", "b.a.example.com."} { |
| + r.Authorities = append(r.Authorities, dnsmessage.Resource{ |
| + Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(owner), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300}, |
| + Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName("ns.provider.net.")}, |
| + }) |
| + } |
| + return true |
| + }) |
| + w := oneZone(parent) |
| + w.hosts["ns.provider.net"] = []string{"192.0.2.40"} |
| + w.routes["192.0.2.40:53"] = child |
| + if ips, err := w.resolver(clock()).Resolve("shop.b.a.example.com"); err == nil { |
| + t.Fatalf("Resolve = %v, want the two-owner referral refused", ips) |
| + } |
| + if child.queries.Load() != 0 || w.cachedFor("ns.provider.net") != 0 { |
| + t.Fatalf("followed a referral naming two zones: dialled %v, cached %v", w.dialed, w.cached) |
| + } |
| +} |
| + |
| +// Fable R3 P2-5: at most freshMaxNSHosts of a zone's nameserver hosts are |
| +// looked up through the cache, however many it lists. |
| +func TestFreshResolverBoundsNameserverHostLookups(t *testing.T) { |
| + w := &world{ns: map[string][]string{"example.com": {}}, hosts: map[string][]string{}} |
| + for i := 0; i < 40; i++ { |
| + w.ns["example.com"] = append(w.ns["example.com"], fmt.Sprintf("ns%d.provider.net.", i)) |
| + } |
| + for name, resolve := range map[string]func(*domains.FreshResolver) func(string) ([]string, error){ |
| + "new name": func(r *domains.FreshResolver) func(string) ([]string, error) { return r.Resolve }, |
| + "published name": func(r *domains.FreshResolver) func(string) ([]string, error) { return r.ResolveUpgrade }, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + w.cached = nil |
| + if _, err := resolve(w.resolver(clock()))("shop.example.com"); err == nil { |
| + t.Fatal("Resolve succeeded with no nameserver address") |
| + } |
| + hosts := 0 |
| + for _, c := range w.cached { |
| + if strings.HasPrefix(c, "HOST ") { |
| + hosts++ |
| + } |
| + } |
| + if hosts != domains.FreshMaxNSHosts { |
| + t.Fatalf("%d cached nameserver-host lookups, want %d: %v", hosts, domains.FreshMaxNSHosts, w.cached) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Fable P2 of the last round: ResolveUpgrade asks the nearest zone FIRST, |
| +// with the whole Timeout. Here the registrable domain's server is silent |
| +// and one attempt at it is all the Timeout there is: asked first, the |
| +// top-down walk would leave the nearest zone no time. |
| +func TestFreshResolverUpgradeAsksTheNearestZoneFirst(t *testing.T) { |
| + w, last := deepWorld(t) |
| + silent := startAuthority(t, "example.com", nil) |
| + w.routes["192.0.2.10:53"] = silent |
| + r := w.resolver(clock()) |
| + r.Timeout, r.AttemptTimeout = 400*time.Millisecond, 400*time.Millisecond |
| + ips, err := r.ResolveUpgrade(deepName) |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("ResolveUpgrade = %v, %v; want [%s] from the nearest zone", ips, err, edgeIP) |
| + } |
| + if last.queries.Load() == 0 || silent.queries.Load() != 0 { |
| + t.Fatalf("nearest zone got %d queries and the registrable domain %d; want the nearest zone alone", last.queries.Load(), silent.queries.Load()) |
| + } |
| +} |
| + |
| +// The nearest-zone look leaves the registrable domain to the top-down walk |
| +// (asked once, not twice) and never asks about the TLD. |
| +func TestFreshResolverUpgradeNearestZones(t *testing.T) { |
| + for name, want := range map[string]string{ |
| + // Directly under the registrable domain: only the name itself is |
| + // tried as a nearest zone, then the walk. |
| + "shop.example.com": "NS shop.example.com,NS example.com,HOST ns1.example.com", |
| + // An apex: the walk alone. Not "NS com". |
| + "example.com": "NS example.com,HOST ns1.example.com", |
| + // Deeper: parent, name, then the walk. |
| + "shop.eu.example.com": "NS eu.example.com,NS shop.eu.example.com,NS example.com,HOST ns1.example.com", |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", authoritative(aRecord(name+".", edgeIP)))) |
| + ips, err := w.resolver(clock()).ResolveUpgrade(name) |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("ResolveUpgrade = %v, %v; want [%s] from the top-down walk", ips, err, edgeIP) |
| + } |
| + if got := strings.Join(w.cached, ","); got != want { |
| + t.Fatalf("cached queries = %s, want %s", got, want) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// onPathWorld is example.com served ONLY by eu.example.com, a host on the |
| +// path of shop.eu.example.com, which points here. |
| +func onPathWorld(t *testing.T) *world { |
| + t.Helper() |
| + fa := startAuthority(t, "example.com", authoritative(aRecord("shop.eu.example.com.", edgeIP))) |
| + return &world{ |
| + ns: map[string][]string{"example.com": {"eu.example.com."}}, |
| + hosts: map[string][]string{"eu.example.com": {"192.0.2.53"}}, |
| + routes: map[string]*fakeAuthority{"192.0.2.53:53": fa}, |
| + } |
| +} |
| + |
| +// Astra P1 of the last round: the on-path nameserver skip is for new names |
| +// only. A published name's look may ask the cache for any nameserver host, |
| +// at the registrable domain and on a referral (glue-less, in the child). |
| +func TestFreshResolverOnPathSkipIsForNewNamesOnly(t *testing.T) { |
| + t.Run("registrable NS set", func(t *testing.T) { |
| + w := onPathWorld(t) |
| + if ips, err := w.resolver(clock()).Resolve("shop.eu.example.com"); err == nil { |
| + t.Fatalf("Resolve = %v, want no server for a new name", ips) |
| + } |
| + noCachedBelow(t, w, "shop.eu.example.com", "example.com") |
| + ips, err := w.resolver(clock()).ResolveUpgrade("shop.eu.example.com") |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("ResolveUpgrade = %v, %v; want [%s]", ips, err, edgeIP) |
| + } |
| + }) |
| + t.Run("referral without glue", func(t *testing.T) { |
| + w := oneZone(startAuthority(t, "example.com", referral("b.a.example.com", ""))) |
| + w.hosts["ns.b.a.example.com"] = []string{"192.0.2.40"} |
| + w.routes["192.0.2.40:53"] = startAuthority(t, "b.a.example.com", authoritative(aRecord("shop.b.a.example.com.", edgeIP))) |
| + ips, err := w.resolver(clock()).ResolveUpgrade("shop.b.a.example.com") |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("ResolveUpgrade = %v, %v; want [%s]", ips, err, edgeIP) |
| + } |
| + }) |
| +} |
| + |
| +// The two-strike map never evicts a pending first strike. Full of them, a |
| +// new failure counts as the second strike and is not recorded. |
| +func TestFreshResolverStrikeMapFullOfPendingStrikes(t *testing.T) { |
| + r := &domains.FreshResolver{} |
| + if r.Strike("shop.example.com") { |
| + t.Fatal("first strike reported as the second") |
| + } |
| + for i := 0; i < 2*domains.FreshMaxBackoff; i++ { |
| + r.Strike(fmt.Sprintf("n%d.example.com", i)) |
| + } |
| + if got := domains.FreshStrikeState(r, "shop.example.com"); got != 1 { |
| + t.Fatalf("pending strike state = %d after the map overflowed, want 1 (kept)", got) |
| + } |
| + if !r.Strike("late.example.com") { |
| + t.Fatal("a new failure with the map full of pending strikes was held; want it to count as the second strike") |
| + } |
| + if got := domains.FreshStrikeState(r, "late.example.com"); got != 0 { |
| + t.Fatalf("late name recorded (%d) in a full map", got) |
| + } |
| + if !r.Strike("shop.example.com") { |
| + t.Fatal("the pending strike was forgotten: its second failure was held again") |
| + } |
| +} |
| + |
| +// Names that have taken their second strike are the ones that make room. |
| +func TestFreshResolverStrikeMapEvictsTakenStrikesFirst(t *testing.T) { |
| + r := &domains.FreshResolver{} |
| + for i := 0; i < domains.FreshMaxBackoff; i++ { |
| + r.Strike(fmt.Sprintf("n%d.example.com", i)) |
| + } |
| + for _, done := range []string{"n7.example.com", "n8.example.com"} { |
| + if !r.Strike(done) { |
| + t.Fatalf("%s: second strike not reported", done) |
| + } |
| + } |
| + for _, fresh := range []string{"x.example.com", "y.example.com"} { |
| + if r.Strike(fresh) { |
| + t.Fatalf("%s: held expected, a taken strike could make room", fresh) |
| + } |
| + if got := domains.FreshStrikeState(r, fresh); got != 1 { |
| + t.Fatalf("%s state = %d, want 1 (pending)", fresh, got) |
| + } |
| + } |
| + for i := 0; i < domains.FreshMaxBackoff; i++ { |
| + n := fmt.Sprintf("n%d.example.com", i) |
| + want := 1 |
| + if i == 7 || i == 8 { |
| + want = 0 |
| + } |
| + if got := domains.FreshStrikeState(r, n); got != want { |
| + t.Fatalf("%s state = %d, want %d: only the taken strikes are evicted", n, got, want) |
| + } |
| + } |
| + if !r.Strike("z.example.com") { |
| + t.Fatal("no taken strike left to evict: the new failure must count as the second strike") |
| + } |
| +} |
| + |
| // Astra R3 P2-3 / Fable P3-4: a nameserver host that is the name or one of |
| // its levels below the registrable domain (a stale NS entry) is never |
| // looked up through the cache, at the registrable domain or on a referral. |
diff --git a/internal/domains/reconcile.go b/internal/domains/reconcile.go| index 6458b652f..72fd69d7e 100644 |
| --- a/internal/domains/reconcile.go |
| +++ b/internal/domains/reconcile.go |
| @@ -46,8 +46,8 @@ type Config struct { |
| // ResolveFresh asks without any cache (#724); see dnsVerdicts. nil |
| // leaves every verdict to Resolve alone. |
| ResolveFresh func(host string) ([]string, error) |
| - // ResolveUpgrade is ResolveFresh for a published name's upgrade look, |
| - // with a fallback to the name's nearest zone (FreshResolver's |
| + // ResolveUpgrade is the fresh look for a published name's upgrade: the |
| + // name's nearest zone first, then ResolveFresh's walk (FreshResolver's |
| // ResolveUpgrade); nil uses ResolveFresh. Never used for a new name. |
| ResolveUpgrade func(host string) ([]string, error) |
| // FreshForget ends ResolveFresh's failure backoff for a host (the same |
| @@ -566,7 +566,7 @@ const unresolvedDNS = "unresolved" |
| // heldDNS is not a stamp: it is dnsVerdicts saying "this pass decided |
| // nothing about this name, leave its stamp and check time alone" (a new |
| -// name's first fresh failure, see dnsVerdicts). Section 4 never writes it. |
| +// name's first fresh failure, see hostVerdicts). Section 4 never writes it. |
| const heldDNS = "\x00held" |
| // dnsStatus resolves host and classifies the answer against edge. Three |
| @@ -628,22 +628,56 @@ var ( |
| // resolver (cfg.Resolve) and, for customer hostnames, an uncached look |
| // (cfg.ResolveFresh, #724). |
| // |
| +// Each hostname is decided ONCE per pass, and the verdict goes to every row |
| +// carrying it (a host can be both a route and an alias). Decided per row, |
| +// the second row's fresh failure would count as the second strike inside |
| +// the same pass and take the cached look the first had just held. A host is |
| +// treated as published if any of its rows was "pointing", and as checked |
| +// when its least recently checked row was. |
| +func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) { |
| + key := func(host string) string { return strings.ToLower(strings.TrimSuffix(host, ".")) } |
| + var hosts []freshCandidate |
| + at := map[string]int{} |
| + for _, c := range candidates { |
| + i, ok := at[key(c.host)] |
| + if !ok { |
| + at[key(c.host)] = len(hosts) |
| + hosts = append(hosts, freshCandidate{c.host, c.prev, c.checked, new(string)}) |
| + continue |
| + } |
| + if c.prev == "pointing" { |
| + hosts[i].prev = "pointing" |
| + } |
| + if c.checked < hosts[i].checked { |
| + hosts[i].checked = c.checked |
| + } |
| + } |
| + hostVerdicts(cfg, edge, hosts) |
| + for _, c := range candidates { |
| + *c.status = *hosts[at[key(c.host)]].status |
| + } |
| +} |
| + |
| +// hostVerdicts is dnsVerdicts for candidates with distinct hostnames. |
| +// |
| // A name that was NOT "pointing" before this pass is looked at fresh |
| // FIRST, and the cached resolver is not asked about it at all unless the |
| -// fresh look fails twice in a row or the name is past the budget. The customer attaches a hostname and then adds the |
| -// record (the order attach prints), so such a name may not exist yet, and |
| -// a cached query for it would plant a "no such name" in systemd-resolved |
| -// and the VPC resolver behind it for the zone's SOA minimum. The cert |
| -// issuer gates its orders on those same caches; if nothing of ours asks |
| -// them about the name before it exists, its first lookup after the record |
| -// goes live is a clean miss. The fresh verdicts are the cached path's: |
| -// addresses including an edge are "pointing", other addresses |
| -// "elsewhere", an authoritative not-found "". An authoritative "exists, |
| -// no A record" takes the cached look (it sees every address family, and |
| -// the name exists). A fresh FAILURE (no authority, backoff, timeout) |
| -// follows the two-strike rule: the first in a row decides nothing (the |
| -// stamp is held and the next pass asks fresh again), the second takes the |
| -// cached look as before #724. |
| +// fresh look fails twice in a row or the name is past the budget. The |
| +// customer attaches a hostname and then adds the record (the order attach |
| +// prints), so such a name may not exist yet, and a cached query for it |
| +// would plant a negative entry in systemd-resolved and the VPC resolver |
| +// behind it for the zone's SOA minimum. The cert issuer gates its orders on |
| +// those same caches; if nothing of ours asks them about the name before it |
| +// exists, its first lookup after the record goes live is a clean miss. The |
| +// fresh verdicts are the cached path's: addresses including an edge are |
| +// "pointing", other addresses "elsewhere", an authoritative not-found "". |
| +// An authoritative "exists, no address record" (NODATA for A and for AAAA, |
| +// each with the zone's SOA; an AAAA record is read and classified like any |
| +// address) is "" too, with no cached query: the cache would keep a |
| +// per-type negative entry for it just as it keeps a "no such name". A |
| +// fresh FAILURE (no authority, backoff, timeout) follows the two-strike |
| +// rule: the first in a row decides nothing (the stamp is held and the next |
| +// pass asks fresh again), the second takes the cached look as before #724. |
| // |
| // A name that WAS "pointing" keeps the cached-first path: a positive cache |
| // entry is cheap and cannot be a primed miss. Its fresh look may only |
| @@ -652,24 +686,24 @@ var ( |
| // verdict as it was. So the fresh path can never unpublish a name: it |
| // decides the verdict only for names that were not "pointing" before this |
| // pass, and a published name stays decided by the cached path plus that |
| -// upgrade, as before. The upgrade look is ResolveUpgrade: top-down like |
| -// any fresh look, then the name's nearest zone if that gives no answer, |
| -// so a published name under a deep delegation is still found. A cached |
| -// lookup that FAILED is not upgraded either: |
| -// that is our resolver's fault, handled by section 4's hold-last-verdict |
| -// rule. |
| +// upgrade, as before. The upgrade look is ResolveUpgrade: the name's |
| +// nearest zone first, as on main, then top-down from the registrable |
| +// domain if that gives no answer. A cached lookup that FAILED is not |
| +// upgraded either: that is our resolver's fault, handled by section 4's |
| +// hold-last-verdict rule. |
| // |
| // Names under the apps domain are the platform's own zone, and names with |
| // no possible public zone (sidecar hosts under .internal) have nothing to |
| // ask; neither is eligible, so neither takes a share of the budget, and |
| // both are stamped by the cached path alone. Eligible names share one |
| -// budget, published names' upgrades first, each group in a random order |
| -// (Astra R1 on the #724 follow-up: new names must not starve a published |
| -// name's re-check and so unpublish it). The pass stops looking fresh after |
| +// budget, published names' upgrades first (Astra R1 on the #724 follow-up: |
| +// new names must not starve a published name's re-check and so unpublish |
| +// it), in a random order; then new names, never-checked first and the |
| +// longest since checked after them. The pass stops looking fresh after |
| // freshPassMax lookups or freshPassTime, so a large backlog is worked |
| // through across passes instead of stretching any one of them. A |
| // not-pointing name past the budget gets the cached look, as before #724. |
| -func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) { |
| +func hostVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) { |
| apps := strings.ToLower(cfg.AppsDomain) |
| eligible := func(host string) bool { |
| h := strings.ToLower(strings.TrimSuffix(host, ".")) |
| @@ -735,8 +769,8 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) |
| } |
| resolve := cfg.ResolveFresh |
| if c.prev == "pointing" && cfg.ResolveUpgrade != nil { |
| - // Published, so it exists: the nearest-zone fallback cannot |
| - // prime anything. A new name NEVER takes this path. |
| + // Published, so it exists: the nearest-zone look cannot prime |
| + // anything. A new name NEVER takes this path. |
| resolve = cfg.ResolveUpgrade |
| } |
| ips, err := resolve(c.host) |
| @@ -750,9 +784,9 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) |
| *c.status = "pointing" |
| } |
| case errors.Is(err, errNoData): |
| - // The name exists with no A record (AAAA only, say): the |
| - // cached look sees every family and primes nothing. |
| - *c.status = dnsStatus(cfg.Resolve, c.host, edge) |
| + // The name exists with no address record of either family. No |
| + // cached look: it would plant the negative #724 is about. |
| + *c.status = "" |
| case fresh == unresolvedDNS: |
| // Two strikes: the first failure in a row decides nothing and |
| // asks nobody else (the resolver forgives it, so the next pass |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 382b9d4bc..dce3bcc75 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -3825,8 +3825,10 @@ func domainsTickConfig(getenv func(string) string, publicIP string) (domains.Con |
| } |
| // #724: the uncached look, first for a customer hostname that is not |
| // published yet and as a second look for one whose cached answer stops |
| - // pointing here. The cached resolver only finds the registrable |
| - // domain's nameservers, nameserver addresses and our own CNAME target. |
| + // pointing here. For a name not yet published the cached resolver only |
| + // finds the registrable domain's nameservers, nameserver addresses and |
| + // our own CNAME target; a published name's look may also ask it for the |
| + // name's nearest zone. |
| fresh := &domains.FreshResolver{ |
| LookupNS: net.DefaultResolver.LookupNS, |
| LookupHost: net.DefaultResolver.LookupHost, |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 453051fa9..6ef423ee4 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -144,4 +144,4 @@ plan14-root-reads-deploy-edge-718.tsv 250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f |
| plan14-root-reads-demo-slice-adopt.tsv 707018faaa1fee3b47abb78389ae7854264e76621cc316889061adb69bf13e10 |
| plan14-root-reads-security-review-mitigations.tsv a6f3f9eec4aac5ea88f20d0e52eaa0651fce80c0d49b60883ff61ceade33d288 |
| plan14-root-reads-cli-registry-words.tsv 8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6 |
| -plan14-root-reads-no-negative-prime-724.tsv 70bb4d8af6dc72d82a629d1c079acf6716a32e3fef5d7ae2b1f2c761b99c614e |
| +plan14-root-reads-no-negative-prime-724.tsv 9d87c4c63726a6f840f22fe624edd90e1071d06d0af7ab87d895ecf64bf6551e |
diff --git a/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv b/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv| index f7e5ad3df..e8278e95e 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-no-negative-prime-724.tsv |
| @@ -1,13 +1,13 @@ |
| # Census overlay no-negative-prime-724, written by census-propose (#369). census-ruling-no-negative-prime-724, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-no-negative-prime-724.md. |
| # 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 3 new dispositions: 1 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| -@legacy 0eaefef4c49973592bda938ef5dce716c9354263a531cb454a04b36ca92723a8 internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: same lookup plus a nearest-zone fallback through the cached NS set, used only for names already "pointing"), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 6e3e65fe420646b3321e0c309d2e821ce99cb58071aee2c47ab15ef067c24ce8 |
| -@legacy 5d212a8ac7796a96174c8f1eb2aa31288c958ad7ec7bbd1705715a2577614e34 internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it no longer checks the authority and truncation flags (exchange still does, for SOA verification; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba |
| -@legacy d8aa81f4c5642ada2e77e51a01cf066e6cdcf5f704642fd8e195b3e9de54be92 internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; a new name's first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again) and only the second takes the cached look; a fresh "exists, no A record" takes the cached look; new names are ordered never-checked first, and lookups answered from the backoff do not count against the budget; a published name's upgrade look uses ResolveUpgrade, which may fall back to the nearest zone; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3189,registry:Alias@3775,registry:Alias@3865,registry:Alias@4299,registry:Alias@4363,registry:Alias@4451,registry:DNSCheckedAt@3067,registry:DNSCheckedAt@3211,registry:DNSStatus@3053,registry:DNSStatus@3198,registry:DNSStatus@3403,registry:DNSStatus@3699,registry:Host@3044,registry:Host@3475,registry:Host@3559,registry:Host@4068,registry:Host@4127,registry:Host@4209,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3310,whole:Route@4022,whole:RouteAlias@2917,whole:RouteAlias@3128,whole:RouteAlias@3605,whole:RouteAlias@4252,whole:RouteAlias@780 a1345c0d3076a9cd7ff17bc95fed36df451b5391dce43eb77d8b5151a6d5fb13 |
| -internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: same lookup plus a nearest-zone fallback through the cached NS set, used only for names already "pointing"), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 6e3e65fe420646b3321e0c309d2e821ce99cb58071aee2c47ab15ef067c24ce8 |
| -internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it no longer checks the authority and truncation flags (exchange still does, for SOA verification; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba |
| -internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address "pointing", other "elsewhere", authoritative not-found ""), falling back to the cached lookup on a fresh error or past the budget; a previously "pointing" name keeps cached-first plus the upgrade-only fresh look, so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; a new name's first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again) and only the second takes the cached look; a fresh "exists, no A record" takes the cached look; new names are ordered never-checked first, and lookups answered from the backoff do not count against the budget; a published name's upgrade look uses ResolveUpgrade, which may fall back to the nearest zone; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3189,registry:Alias@3775,registry:Alias@3865,registry:Alias@4299,registry:Alias@4363,registry:Alias@4451,registry:DNSCheckedAt@3067,registry:DNSCheckedAt@3211,registry:DNSStatus@3053,registry:DNSStatus@3198,registry:DNSStatus@3403,registry:DNSStatus@3699,registry:Host@3044,registry:Host@3475,registry:Host@3559,registry:Host@4068,registry:Host@4127,registry:Host@4209,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3310,whole:Route@4022,whole:RouteAlias@2917,whole:RouteAlias@3128,whole:RouteAlias@3605,whole:RouteAlias@4252,whole:RouteAlias@780 a1345c0d3076a9cd7ff17bc95fed36df451b5391dce43eb77d8b5151a6d5fb13 |
| +@legacy 0e9e81495dd4b48f0fa257c7205f21e80fc264403b955ca1132c7d95169f5c4c internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: for names already "pointing" only, asks the name's nearest zone through the cached NS set first and then the same top-down walk), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; comment updated to say which cached lookups each path makes; reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 1c5aa9fb0323faa4e2b0c63bf1a694e8a55b7fa4b58c76ed2179570144fcbad2 |
| +@legacy dc4ebc033f359e686e43d094ca7cf0b8e4b301327766281086016f7f15295fde internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it takes the question type as an argument (A, SOA, and now AAAA after a NODATA for A, to the same verified server) and no longer checks the authority and truncation flags (exchange still does, for SOA verification and the AAAA question; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba |
| +@legacy ca44a669b23b8e1290a00e4335b6c0d8748b5be12e5cf5670f2fd74738442c9b internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts, which decides each hostname once per pass and applies the verdict to every row carrying it: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address, A or AAAA, "pointing", other "elsewhere", authoritative not-found "", authoritative NODATA for A and AAAA with the zone's SOA "" with no cached query), falling back to the cached lookup past the budget or on the second fresh failure in a row; the first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again); a previously "pointing" name keeps cached-first plus the upgrade-only fresh look (ResolveUpgrade, nearest zone first), so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; new names are ordered never-checked first then oldest check, and lookups answered from the backoff do not count against the budget; StampHealth's own body is unchanged by the last round; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3189,registry:Alias@3775,registry:Alias@3865,registry:Alias@4299,registry:Alias@4363,registry:Alias@4451,registry:DNSCheckedAt@3067,registry:DNSCheckedAt@3211,registry:DNSStatus@3053,registry:DNSStatus@3198,registry:DNSStatus@3403,registry:DNSStatus@3699,registry:Host@3044,registry:Host@3475,registry:Host@3559,registry:Host@4068,registry:Host@4127,registry:Host@4209,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3310,whole:Route@4022,whole:RouteAlias@2917,whole:RouteAlias@3128,whole:RouteAlias@3605,whole:RouteAlias@4252,whole:RouteAlias@780 a1345c0d3076a9cd7ff17bc95fed36df451b5391dce43eb77d8b5151a6d5fb13 |
| +internal/host/agent.go domainsTickConfig legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-dns-fresh-lookup-724;basis=wires ResolveFresh to a FreshResolver over net.DefaultResolver (LookupNS, LookupHost, LookupCNAME) (#724);rev3=census-ruling-no-negative-prime-724;basis=builds the one FreshResolver per config as a local and wires four of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: for names already "pointing" only, asks the name's nearest zone through the cached NS set first and then the same top-down walk), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host) and Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure); drops LookupCNAME from the resolver; comment updated to say which cached lookups each path makes; reads nothing new, no file, path, env var or command input added (#724) data-literal@469,data-literal@510 1c5aa9fb0323faa4e2b0c63bf1a694e8a55b7fa4b58c76ed2179570144fcbad2 |
| +internal/domains/freshdns.go FreshResolver.query legacy accepted-legacy accepted-legacy;rev3=census-ruling-no-negative-prime-724;basis=new: the body of the old FreshResolver.exchange moved here unchanged except that it takes the question type as an argument (A, SOA, and now AAAA after a NODATA for A, to the same verified server) and no longer checks the authority and truncation flags (exchange still does, for SOA verification and the AAAA question; ask checks truncation and reads a non-authoritative reply only as a referral down the name's path). The file:Read is the same conn.Read of one UDP reply from a nameserver that passed publicNameserver, with the same exact question matching; no file, path or new input (#724) file:Read@1214 f91e835feced403f06169f7fbec3816dbf5b4b53177915197b61a1ee40bff8ba |
| +internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts, which decides each hostname once per pass and applies the verdict to every row carrying it: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address, A or AAAA, "pointing", other "elsewhere", authoritative not-found "", authoritative NODATA for A and AAAA with the zone's SOA "" with no cached query), falling back to the cached lookup past the budget or on the second fresh failure in a row; the first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again); a previously "pointing" name keeps cached-first plus the upgrade-only fresh look (ResolveUpgrade, nearest zone first), so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; new names are ordered never-checked first then oldest check, and lookups answered from the backoff do not count against the budget; StampHealth's own body is unchanged by the last round; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) registry:Alias@3189,registry:Alias@3775,registry:Alias@3865,registry:Alias@4299,registry:Alias@4363,registry:Alias@4451,registry:DNSCheckedAt@3067,registry:DNSCheckedAt@3211,registry:DNSStatus@3053,registry:DNSStatus@3198,registry:DNSStatus@3403,registry:DNSStatus@3699,registry:Host@3044,registry:Host@3475,registry:Host@3559,registry:Host@4068,registry:Host@4127,registry:Host@4209,whole:Route@199,whole:Route@236,whole:Route@2871,whole:Route@2984,whole:Route@3310,whole:Route@4022,whole:RouteAlias@2917,whole:RouteAlias@3128,whole:RouteAlias@3605,whole:RouteAlias@4252,whole:RouteAlias@780 a1345c0d3076a9cd7ff17bc95fed36df451b5391dce43eb77d8b5151a6d5fb13 |
| @remove internal/domains/freshdns.go FreshResolver.exchange |
| @removed internal/domains/freshdns.go FreshResolver.exchange H3 census-ruling-no-negative-prime-724;basis=quiet: now a wrapper over query that keeps the authority and truncation checks; its socket read moved to FreshResolver.query (#724) |
| -@coverage internal/domains 9517c8523e923180fa3e6af4cdb74ccea68d6cafb161abbe33dc2ef3d9dad782 |
| -@coverage internal/host 010f9023d5ea24fab9b0c0a2d6320e1cd5a22272eae09d5effe30382fd41a4d7 |
| +@coverage internal/domains 8aebb158aa7dcb47989ef8e1b8a0bab0226c31d3095ea4803a117f48367943d2 |
| +@coverage internal/host 306615a57fb5b2b3bf94cce44950726cad083d72c4e5c6e3aea569148710a392 |