domains: co-hosted child zones, ancestor climb, strike reclaim (#724)
Astra's findings on 259abef0. A server holding a zone and a child delegated from it answers for a name in the child under the child's SOA and never refers. That reply is now a hint: the child is verified by its own SOA on the same server (then the zone's others) and asked again, with no cached query and inside the referral bound. The mismatched SOA is never trusted, and an owner off the name's path is no hint. A published name's nearest look climbs every level below the registrable domain through cached NS sets, as main did, trying at most three levels that have one, so a label that is no zone between the name and a deeply delegated zone no longer unpublishes it. New names never climb. Section 4 hands the resolver its hostnames once per pass (Retain), so strikes and backoffs of removed names are dropped instead of filling the strike map. The cost comments are recomputed (21 exchanges and 22 cached calls for Resolve; 39 and 40 plus the name's levels for ResolveUpgrade) and counted by fixtures. The dedupe tests cover mixed publication state in both row orders and the oldest check time.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
9 files changed,
+782
−102
docs/superpowers/notes/census-proposal-no-negative-prime-724.md+2 −2internal/domains/freshdns.go+167 −50internal/domains/freshdns_stamp_test.go+194 −32internal/domains/freshdns_test.go+386 −3internal/domains/reconcile.go+19 −3internal/host/agent.go+3 −1internal/host/host_test.go+2 −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 957be7cc8..3a8fbc395 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: 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) | |
| +| `internal/host/agent.go` `domainsTickConfig` | body | unchanged (2) | builds the one FreshResolver per config as a local and wires five of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: for names already "pointing" only, asks the name's nearest zones first, climbing its levels below the registrable domain through cached NS sets, at most three levels that have one, and then the same top-down walk), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host), Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure) and Retain (new FreshRetain, drops that resolver's in-memory backoff and strike entries for names not in the pass's route and alias hostnames; it only deletes map entries, sends and reads nothing); 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` → `9d87c4c63726a6f840f22fe624edd90e1071d06d0af7ab87d895ecf64bf6551e`. |
| +Seal: `8924fafc5b6083858a72f45c764081abe3bcad6a6de71901470586c076c64bb6` → `ab10145ee873e26b87a653f728cd0c9737592fefe94b659ac5988201c195cb7a`. |
| 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/freshdns.go b/internal/domains/freshdns.go| index 570d9e700..cae8eeb3f 100644 |
| --- a/internal/domains/freshdns.go |
| +++ b/internal/domains/freshdns.go |
| @@ -21,7 +21,8 @@ import ( |
| // domain, asks that zone's own nameservers, and trusts only an |
| // authoritative reply to the exact question it sent. Config.ResolveFresh is |
| // its Resolve, Config.ResolveUpgrade its ResolveUpgrade, Config.FreshForget |
| -// its Forget and Config.FreshStrike its Strike. |
| +// its Forget, Config.FreshStrike its Strike and Config.FreshRetain its |
| +// Retain. |
| // |
| // Why not just skip the box's cache: systemd-resolved is not the only |
| // cache between us and the customer's zone. The upstream (VPC) resolver |
| @@ -105,11 +106,11 @@ const ( |
| // freshMaxServers bounds the nameserver addresses tried per zone, so a |
| // zone of silent servers leaves time for the referral below it. |
| 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 has asked its nearest |
| - // zone before that (ResolveUpgrade); a new name falls to the rules in |
| - // section 4. |
| + // freshMaxZones bounds the referrals (and co-hosted child zones, see |
| + // zoneHint) followed below the registrable domain: up to four zones in |
| + // all. Deeper delegation fails the top-down walk. A published name's |
| + // upgrade look has asked up to freshMaxZones of its nearest zones |
| + // before that (nearest); a new name falls to the rules in section 4. |
| freshMaxZones = 3 |
| // freshMaxCNAMEs bounds a CNAME chain inside one reply. |
| freshMaxCNAMEs = 8 |
| @@ -150,9 +151,9 @@ func (r *FreshResolver) Resolve(host string) ([]string, error) { |
| } |
| // 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 |
| +// so exists. It asks the name's nearest zones FIRST, found by climbing |
| +// from the name through cached NS sets (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 |
| @@ -245,6 +246,31 @@ func (r *FreshResolver) Forget(host string) { |
| r.mu.Unlock() |
| } |
| +// Retain forgets the failure backoff and the strike of every name that is |
| +// not in hosts. Section 4 hands it the deployment's hostnames once per |
| +// pass, so a name that failed once and was then removed gives its place in |
| +// the strike map back; left there, such pending strikes would fill the map |
| +// and send every later failure straight to the cached look (see Strike). A |
| +// name still in hosts keeps both, a pending first strike included. |
| +func (r *FreshResolver) Retain(hosts []string) { |
| + keep := make(map[string]bool, len(hosts)) |
| + for _, h := range hosts { |
| + keep[strings.ToLower(strings.TrimSuffix(h, "."))] = true |
| + } |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + for n := range r.failedAt { |
| + if !keep[n] { |
| + delete(r.failedAt, n) |
| + } |
| + } |
| + for n := range r.struck { |
| + if !keep[n] { |
| + delete(r.struck, n) |
| + } |
| + } |
| +} |
| + |
| // Strike is section 4's two-strike rule for a NEW name whose fresh look |
| // failed (Fable R3 on #724). The first failure in a row is forgiven: its |
| // backoff is cleared so the next pass asks fresh again, and Strike reports |
| @@ -259,6 +285,8 @@ func (r *FreshResolver) Forget(host string) { |
| // 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. |
| +// Retain keeps that last case rare: only names the deployment still carries |
| +// hold a place. |
| func (r *FreshResolver) Strike(host string) (second bool) { |
| name := strings.ToLower(strings.TrimSuffix(host, ".")) |
| r.mu.Lock() |
| @@ -345,9 +373,13 @@ func registrableDomain(name string) (string, bool) { |
| // becomes zone, its servers come from the referral (glue only for |
| // nameservers inside the child zone, the cached LookupHost for the |
| // rest), and step 2 runs again, verifying the child before trusting |
| -// it. At most freshMaxZones referrals. Anything else from a server |
| -// (an error, a referral off the path, an unverified zone) moves on to |
| -// the next server, and when none is left the lookup fails. |
| +// it. A HINT (an authoritative empty reply under the SOA of such a |
| +// child: the server holds the child zone too, see zoneHint) is |
| +// followed the same way with the servers already in hand, the hinting |
| +// one first; the cache is asked nothing. At most freshMaxZones |
| +// referrals and hints together. Anything else from a server (an |
| +// error, a referral or hint off the path, an unverified zone) moves on |
| +// to the next server, and when none is left the lookup fails. |
| // |
| // Why: the cached resolver (systemd-resolved, then the VPC resolver) caches |
| // a "no such name" for a NAME, whatever type was asked (RFC 2308 section |
| @@ -364,13 +396,27 @@ func registrableDomain(name string) (string, bool) { |
| // 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, 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. |
| +// Cost, worst case, all inside Timeout (each exchange also inside |
| +// AttemptTimeout). A zone is asked through up to freshMaxServers servers, |
| +// and a server costs at most three exchanges: SOA, A, and AAAA after a |
| +// NODATA. A zone that hands the walk on does so with its last server's A |
| +// reply, so it costs at most 3 + 2 = 5 (the first server answers NODATA |
| +// and then fails the AAAA exchange, the second refers); the zone the walk |
| +// ends in costs at most 3 + 3 = 6. With 1 + freshMaxZones zones that is |
| +// 3*5 + 6 = 21 authoritative exchanges. A hint costs what a referral does. |
| +// Cached: one LookupNS; LookupHost for at most freshMaxNSHosts nameserver |
| +// hosts per zone, 16 in all (fewer once freshMaxServers IPv4 addresses are |
| +// found; none for a zone reached by a hint); and one LookupHost per reply |
| +// that ends in an out-of-zone CNAME target, which a failed lookup repeats |
| +// on the next server: one in each zone that hands on, two in the last, 5 |
| +// in all. 22 cached calls. The two maxima need different replies from the |
| +// same servers, so no one lookup reaches both. |
| +// |
| +// ResolveUpgrade adds nearest's share before the walk: up to freshMaxZones |
| +// zones at 6 exchanges each, 18, so 39 exchanges; and one LookupNS per |
| +// level of the name below the registrable domain (L of them, the name |
| +// included; only levels WITH an NS set are capped), plus for each of those |
| +// zones 4 nameserver hosts and 2 CNAME targets, 18, so 40 + L cached calls. |
| // |
| // 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 |
| @@ -400,31 +446,55 @@ func (r *FreshResolver) resolve(ctx context.Context, name string, upgrade bool) |
| 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, upgrade) |
| + if ref.hint { |
| + // The same servers, the one that named the child first. No |
| + // cached query: nothing new was learned about where to ask. |
| + for i, s := range servers { |
| + if s == ref.from { |
| + servers[0], servers[i] = servers[i], servers[0] |
| + } |
| + } |
| + } else { |
| + servers = r.serverAddrs(ctx, name, registrable, ref.zone, ref.hosts, ref.glue, upgrade) |
| + } |
| zone = ref.zone |
| } |
| } |
| -// 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. |
| +// nearest is ResolveUpgrade's first look for a published name. It climbs |
| +// the name's levels asking the cached LookupNS at each, as main's lookup |
| +// did: the immediate parent, the name itself (a delegated sub-zone, which |
| +// the parent only refers to), then each ancestor above the parent. A level |
| +// with no NS set is no zone: it is skipped and costs nothing more. A level |
| +// with one is verified and asked like any zone, and up to freshMaxZones of |
| +// those are tried, all inside the same Timeout. So a name with labels that |
| +// are not zones between it and its zone (shop.eu.a.b.c.d.example.com |
| +// served by a.b.c.d.example.com) is found however deep that zone is |
| +// delegated, which the top-down walk alone cannot do past freshMaxZones |
| +// referrals. |
| +// |
| +// The climb stops below the registrable domain, which is left to the |
| +// top-down walk that follows and starts there: 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). The climb asks 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, ok := registrableDomain(name) |
| var last error = fmt.Errorf("%w: no zone near %s", errNoAuthority, name) |
| if !ok || name == registrable { |
| return nil, last |
| } |
| - zones := []string{name} |
| - if parent := name[strings.Index(name, ".")+1:]; parent != registrable { |
| - zones = []string{parent, name} |
| + parent := func(n string) string { return n[strings.Index(n, ".")+1:] } |
| + levels := []string{name} |
| + if up := parent(name); up != registrable { |
| + levels = []string{up, name} |
| + for up = parent(up); up != registrable && strings.Contains(up, "."); up = parent(up) { |
| + levels = append(levels, up) |
| + } |
| } |
| - for _, zone := range zones { |
| + zones := 0 |
| + for _, zone := range levels { |
| nss, err := r.LookupNS(ctx, zone) |
| if err == nil && len(nss) > 0 { |
| hosts := make([]string, len(nss)) |
| @@ -438,6 +508,9 @@ func (r *FreshResolver) nearest(ctx context.Context, name string) ([]string, err |
| if err != nil { |
| last = err |
| } |
| + if zones++; zones >= freshMaxZones { |
| + break |
| + } |
| } |
| if ctx.Err() != nil { |
| break |
| @@ -448,7 +521,7 @@ func (r *FreshResolver) nearest(ctx context.Context, name string) ([]string, err |
| // askZone asks servers, which the caller found for zone, about name, one |
| // at a time: each is verified to hold zone first. It returns the first |
| -// definitive answer or valid referral, else the last failure. |
| +// definitive answer, valid referral or valid hint, else the last failure. |
| func (r *FreshResolver) askZone(ctx context.Context, servers []netip.AddrPort, name, zone string) ([]string, *referral, error) { |
| var last error = fmt.Errorf("%w: no public address for any nameserver of %s", errNoAuthority, zone) |
| for _, s := range servers { |
| @@ -467,11 +540,15 @@ func (r *FreshResolver) askZone(ctx context.Context, servers []netip.AddrPort, n |
| } |
| // referral is a server's "ask the child zone": the child's apex, its NS |
| -// hosts, and glue addresses for the hosts inside it. |
| +// hosts, and glue addresses for the hosts inside it. A hint is the other |
| +// way a server names a child zone (zoneHint): it has no hosts or glue, only |
| +// the server it came from, which is where the child is looked for first. |
| type referral struct { |
| zone string |
| hosts []string |
| glue map[string][]netip.Addr |
| + hint bool |
| + from netip.AddrPort |
| } |
| // serverAddrs resolves zone's NS hosts (in random order) and keeps up to |
| @@ -680,7 +757,8 @@ func (r *FreshResolver) verifyZone(ctx context.Context, server netip.AddrPort, z |
| // 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). |
| +// the same server, and an empty reply under a child zone's SOA comes back |
| +// as a hint (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 { |
| @@ -696,8 +774,7 @@ func (r *FreshResolver) ask(ctx context.Context, server netip.AddrPort, name, zo |
| } |
| return nil, ref, nil |
| } |
| - ips, err := r.answer(ctx, reply, server, name, zone) |
| - return ips, nil, err |
| + return r.answer(ctx, reply, server, name, zone) |
| } |
| // referralFrom reads a non-authoritative reply as a delegation. It must |
| @@ -766,6 +843,39 @@ func noData(reply *dnsmessage.Message, zone string) bool { |
| return false |
| } |
| +// zoneHint reads reply, an authoritative reply to name's A query from a |
| +// server verified for zone, as a DISCOVERY HINT: success, no answer, and in |
| +// the authority section one IN SOA whose owner is strictly below zone and |
| +// at or above name. A server that holds both a zone and a child delegated |
| +// from it (example.com and eu.example.com) answers for a name in the child |
| +// from the child, with the child's SOA, and never refers. noData rightly |
| +// refuses that reply as proof of anything: the SOA is not the verified |
| +// zone's. But it names the one place the answer can be, so the caller |
| +// verifies that child like any referred zone (its own SOA, with authority, |
| +// from this server or the zone's others) and asks again under it. The |
| +// reply itself is never trusted: an owner off the name's path is no hint, |
| +// and a child that does not verify is a failure. "" when reply is no hint. |
| +func zoneHint(reply *dnsmessage.Message, name, zone string) string { |
| + if reply.RCode != dnsmessage.RCodeSuccess || len(reply.Answers) != 0 { |
| + return "" |
| + } |
| + child := "" |
| + for _, rr := range reply.Authorities { |
| + if _, ok := rr.Body.(*dnsmessage.SOAResource); !ok || rr.Header.Class != dnsmessage.ClassINET { |
| + continue |
| + } |
| + owner := strings.ToLower(strings.TrimSuffix(rr.Header.Name.String(), ".")) |
| + if child != "" && owner != child { |
| + return "" |
| + } |
| + child = owner |
| + } |
| + if !strings.HasSuffix(child, "."+zone) || (child != name && !strings.HasSuffix(name, "."+child)) { |
| + return "" |
| + } |
| + return child |
| +} |
| + |
| // 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 |
| @@ -793,15 +903,16 @@ func (r *FreshResolver) answerAAAA(ctx context.Context, server netip.AddrPort, n |
| 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) { |
| +// answer reads an authoritative reply to name's A query from server: the |
| +// addresses, a hint to a co-hosted child zone (zoneHint), or an error. |
| +func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, server netip.AddrPort, name, zone string) ([]string, *referral, error) { |
| fqdn := name + "." |
| switch reply.RCode { |
| case dnsmessage.RCodeSuccess: |
| case dnsmessage.RCodeNameError: |
| - return nil, &net.DNSError{Err: "no such host", Name: name, Server: server.String(), IsNotFound: true} |
| + return nil, nil, &net.DNSError{Err: "no such host", Name: name, Server: server.String(), IsNotFound: true} |
| default: |
| - return nil, fmt.Errorf("%w: %s answered %s for %s", errNoAuthority, server, reply.RCode, name) |
| + return nil, nil, fmt.Errorf("%w: %s answered %s for %s", errNoAuthority, server, reply.RCode, name) |
| } |
| current := fqdn |
| @@ -819,7 +930,7 @@ func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, s |
| break |
| } |
| if seen[next] || hops >= freshMaxCNAMEs { |
| - return nil, fmt.Errorf("%w: CNAME chain from %s loops or runs too long", errNoAuthority, name) |
| + return nil, nil, fmt.Errorf("%w: CNAME chain from %s loops or runs too long", errNoAuthority, name) |
| } |
| seen[next] = true |
| current = next |
| @@ -832,22 +943,28 @@ func (r *FreshResolver) answer(ctx context.Context, reply *dnsmessage.Message, s |
| } |
| } |
| if len(ips) > 0 { |
| - return ips, nil |
| + return ips, nil, nil |
| } |
| target := strings.TrimSuffix(current, ".") |
| if target == name { |
| // 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) |
| + // same server is asked for AAAA. Under a child zone's SOA the |
| + // reply decides nothing, but says where to look. |
| + if noData(reply, zone) { |
| + ips, err := r.answerAAAA(ctx, server, name, zone) |
| + return ips, nil, err |
| } |
| - return r.answerAAAA(ctx, server, name, zone) |
| + if child := zoneHint(reply, name, zone); child != "" { |
| + return nil, &referral{zone: child, hint: true, from: server}, nil |
| + } |
| + return nil, nil, fmt.Errorf("%w: %s gave no answer and no SOA of %s for %s", errNoAuthority, server, zone, name) |
| } |
| if target == zone || strings.HasSuffix(target, "."+zone) { |
| // In-zone target this server gave no address for: no fallback to |
| // a cache that may hold an old one. |
| - return nil, fmt.Errorf("%w: %s ends at in-zone %s with no address", errNoAuthority, name, target) |
| + return nil, nil, fmt.Errorf("%w: %s ends at in-zone %s with no address", errNoAuthority, name, target) |
| } |
| - return r.LookupHost(ctx, target) |
| + ips, err := r.LookupHost(ctx, target) |
| + return ips, nil, err |
| } |
diff --git a/internal/domains/freshdns_stamp_test.go b/internal/domains/freshdns_stamp_test.go| index 3db5119d1..78b4fe1dc 100644 |
| --- a/internal/domains/freshdns_stamp_test.go |
| +++ b/internal/domains/freshdns_stamp_test.go |
| @@ -569,6 +569,7 @@ func newRealFresh(t *testing.T) *realFresh { |
| ResolveUpgrade: fresh.ResolveUpgrade, |
| FreshForget: fresh.Forget, |
| FreshStrike: fresh.Strike, |
| + FreshRetain: fresh.Retain, |
| Now: func() time.Time { return *rf.now }, |
| } |
| return rf |
| @@ -695,8 +696,8 @@ func aliasRow(t *testing.T, reg *registry.Registry, alias string) registry.Route |
| } |
| // deepCfg is production wiring over deepWorld, with a cached resolver that |
| -// says NXDOMAIN for deepName and counts its queries. |
| -func deepCfg(t *testing.T, asked map[string]int) (domains.Config, *world) { |
| +// says NXDOMAIN for name and counts its queries. |
| +func deepCfg(t *testing.T, name string, asked map[string]int) (domains.Config, *world) { |
| t.Helper() |
| w, _ := deepWorld(t) |
| fresh := w.resolver(clock()) |
| @@ -704,7 +705,7 @@ func deepCfg(t *testing.T, asked map[string]int) (domains.Config, *world) { |
| AppsDomain: "oncarlos.test", |
| EdgeIPs: func() []string { return []string{edgeIP} }, |
| Resolve: counted(func(h string) ([]string, error) { |
| - if h == deepName { |
| + if h == name { |
| return nxdomain(h) |
| } |
| return pointingAt(h) |
| @@ -713,40 +714,44 @@ func deepCfg(t *testing.T, asked map[string]int) (domains.Config, *world) { |
| ResolveUpgrade: fresh.ResolveUpgrade, |
| FreshForget: fresh.Forget, |
| FreshStrike: fresh.Strike, |
| + FreshRetain: fresh.Retain, |
| Now: func() time.Time { return time.Unix(5000, 0) }, |
| }, w |
| } |
| -// INVARIANT GUARD (Astra R3 P1 on #724): a published name under a |
| -// delegation deeper than the top-down walk follows stays published: its |
| -// upgrade look falls back to the nearest zone. The same name as a NEW |
| -// candidate never takes that fallback: nothing below the registrable |
| -// domain reaches the cache. |
| +// INVARIANT GUARD (Astra R3 P1 on #724, and P1 on 259abef0): a published |
| +// name under a delegation deeper than the top-down walk follows stays |
| +// published: its upgrade look asks the nearest zones, climbing past a |
| +// label that is no zone (deepGapName) as main did. The same name as a NEW |
| +// candidate never takes that look: nothing below the registrable domain |
| +// reaches the cache. |
| func TestStampHealthDeepDelegation(t *testing.T) { |
| - t.Run("published", func(t *testing.T) { |
| - asked := map[string]int{} |
| - cfg, _ := deepCfg(t, asked) |
| - reg := regWithAlias(t, deepName) |
| - stampAlias(t, reg, deepName, "pointing") |
| - if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| - t.Fatal(err) |
| - } |
| - if got := aliasStatus(t, reg, deepName); got != "pointing" { |
| - t.Fatalf("published alias = %q, want pointing", got) |
| - } |
| - }) |
| - t.Run("new", func(t *testing.T) { |
| - asked := map[string]int{} |
| - cfg, w := deepCfg(t, asked) |
| - reg := regWithAlias(t, deepName) |
| - if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| - t.Fatal(err) |
| - } |
| - noCachedBelow(t, w, deepName, "example.com") |
| - if asked[deepName] != 0 { |
| - t.Fatalf("cached resolver asked about %s on the first failure", deepName) |
| - } |
| - }) |
| + for _, name := range []string{deepName, deepGapName} { |
| + t.Run("published "+name, func(t *testing.T) { |
| + asked := map[string]int{} |
| + cfg, _ := deepCfg(t, name, asked) |
| + 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 "+name, func(t *testing.T) { |
| + asked := map[string]int{} |
| + cfg, w := deepCfg(t, 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 on the first failure", name) |
| + } |
| + }) |
| + } |
| } |
| // worldCfg is production wiring over w's resolver, with a cached resolver |
| @@ -766,6 +771,7 @@ func worldCfg(w *world, name string, asked map[string]int, edges ...string) (dom |
| ResolveUpgrade: fresh.ResolveUpgrade, |
| FreshForget: fresh.Forget, |
| FreshStrike: fresh.Strike, |
| + FreshRetain: fresh.Retain, |
| Now: func() time.Time { return time.Unix(5000, 0) }, |
| }, fresh |
| } |
| @@ -1026,3 +1032,159 @@ func TestStampHealthPublishedNamePastTheBudget(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// INVARIANT GUARD (Astra P1 on 259abef0): one server holds example.com and |
| +// the delegated eu.example.com, and shop.eu.example.com has only a TXT |
| +// record. The server answers from the child, under the child's SOA; the |
| +// child is verified and asked, and the name is stamped "" on the first |
| +// pass. Across two passes the cache hears nothing about the name: read as |
| +// a failure instead, the second pass would take the cached look and plant |
| +// the negative entry #724 is about. |
| +func TestStampHealthCoHostedChildZoneNeverAsksTheCache(t *testing.T) { |
| + const name = "shop.eu.example.com" |
| + w := oneZone(startAuthority(t, "", cohost(nodata("eu.example.com"), "example.com", "eu.example.com"))) |
| + asked := map[string]int{} |
| + cfg, _ := worldCfg(w, name, asked) |
| + reg := regWithAlias(t, name) |
| + for pass := 1; pass <= 2; pass++ { |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if a := aliasRow(t, reg, name); a.DNSStatus != "" || a.DNSCheckedAt == 0 { |
| + t.Fatalf("pass %d: alias stamp = %q at %d, want \"\" stamped", pass, a.DNSStatus, a.DNSCheckedAt) |
| + } |
| + if asked[name] != 0 { |
| + t.Fatalf("pass %d: cached resolver asked about %s %d times, want 0", pass, name, asked[name]) |
| + } |
| + noCachedBelow(t, w, name, "example.com") |
| + } |
| +} |
| + |
| +// INVARIANT GUARD (Astra P2 on 259abef0): names that failed once and were |
| +// then removed do not keep their places in the strike map. Here the map is |
| +// full of such pending strikes; the pass hands the resolver its hostnames, |
| +// they are dropped, and a new name's first failure is held as usual. Left |
| +// there, they would make it count as the second strike and take the cached |
| +// look at once. |
| +func TestStampHealthRemovedNamesGiveTheirStrikesBack(t *testing.T) { |
| + const name = "shop.example.com" |
| + w := oneZone(startAuthority(t, "example.com", nil)) |
| + asked := map[string]int{} |
| + cfg, fresh := worldCfg(w, name, asked) |
| + reg := regWithAlias(t, name) |
| + for i := 0; i < domains.FreshMaxBackoff; i++ { |
| + fresh.Strike(fmt.Sprintf("gone%d.example.net", i)) |
| + } |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if asked[name] != 0 || aliasRow(t, reg, name).DNSCheckedAt != 0 { |
| + t.Fatalf("pass A: cached asked %d times; want the first failure held, the removed names' strikes reclaimed", asked[name]) |
| + } |
| + if got := domains.FreshStrikeState(fresh, "gone7.example.net"); got != 0 { |
| + t.Fatalf("removed name's strike state = %d, want 0", got) |
| + } |
| + // The name is still carried, so its pending strike survives the next |
| + // pass's Retain: the second failure takes the cached look. |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if asked[name] != 1 { |
| + t.Fatalf("pass B: cached asked %d times, want 1 (second strike)", asked[name]) |
| + } |
| +} |
| + |
| +// twoRows is a registry carrying name as both a route and an alias. |
| +func twoRows(t *testing.T, name string) *registry.Registry { |
| + t.Helper() |
| + 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) |
| + } |
| + return reg |
| +} |
| + |
| +// Astra P3 on 259abef0: a hostname with one row "pointing" and one not is |
| +// PUBLISHED, whichever row comes first. It is decided once, by the cached |
| +// look and the upgrade look, never fresh-first; with the cache stale and |
| +// the upgrade succeeding, both rows end "pointing". |
| +func TestStampHealthMixedRowsArePublished(t *testing.T) { |
| + const name = "shop.example.com" |
| + for _, pointing := range []string{"route", "alias"} { |
| + t.Run(pointing+" row pointing", func(t *testing.T) { |
| + reg := twoRows(t, name) |
| + var err error |
| + if pointing == "route" { |
| + err = reg.SetDNSStatus(name, "pointing", 4000) |
| + } else { |
| + err = reg.SetAliasDNSStatus(name, "pointing", 4000) |
| + } |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + asked := map[string]int{} |
| + var firsts, upgrades []string |
| + cfg := freshCfg(counted(func(h string) ([]string, error) { |
| + if h == name { |
| + return nxdomain(h) |
| + } |
| + return pointingAt(h) |
| + }, asked), nxdomain, &firsts) |
| + cfg.ResolveUpgrade = func(h string) ([]string, error) { |
| + upgrades = append(upgrades, h) |
| + return pointingAt(h) |
| + } |
| + if err := domains.StampHealth(context.Background(), reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(firsts) != 0 || len(upgrades) != 1 || asked[name] != 1 { |
| + t.Fatalf("fresh-first looks %v, upgrade looks %v, cached looks %d; want none, one and one", firsts, upgrades, asked[name]) |
| + } |
| + if rt, a := mustGet(t, reg, name), aliasRow(t, reg, name); rt.DNSStatus != "pointing" || a.DNSStatus != "pointing" { |
| + t.Fatalf("route %q, alias %q; want both pointing", rt.DNSStatus, a.DNSStatus) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// And its place in the fresh budget is its least recently checked row's, |
| +// whichever row that is: checked at 100 and 300, it goes before a name |
| +// checked at 200. |
| +func TestStampHealthDuplicateRowsTakeTheOldestCheck(t *testing.T) { |
| + defer domains.SetFreshPassMax(1)() |
| + const name = "shop.example.com" |
| + for _, oldest := range []string{"route", "alias"} { |
| + t.Run(oldest+" row oldest", func(t *testing.T) { |
| + for trial := 0; trial < 10; trial++ { |
| + reg := twoRows(t, name) |
| + routeAt, aliasAt := int64(100), int64(300) |
| + if oldest == "alias" { |
| + routeAt, aliasAt = 300, 100 |
| + } |
| + if err := reg.SetDNSStatus(name, "elsewhere", routeAt); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.SetAliasDNSStatus(name, "elsewhere", aliasAt); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: "other.example.com", Host: "app.acct.oncarlos.test", Account: "acct", App: "app"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.SetAliasDNSStatus("other.example.com", "elsewhere", 200); 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] != name { |
| + t.Fatalf("fresh lookups = %v, want [%s]: the duplicate's oldest check is 100", calls, name) |
| + } |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/domains/freshdns_test.go b/internal/domains/freshdns_test.go| index 190fa0d63..8af6496f1 100644 |
| --- a/internal/domains/freshdns_test.go |
| +++ b/internal/domains/freshdns_test.go |
| @@ -659,9 +659,13 @@ func TestFreshResolverRefusesAReferralOffThePath(t *testing.T) { |
| // deepName sits four delegations below example.com, past freshMaxZones. |
| const deepName = "shop.a.b.c.d.example.com" |
| +// deepGapName sits in the same last zone under a label that is no zone |
| +// (eu): neither it nor its immediate parent has an NS set. |
| +const deepGapName = "shop.eu.a.b.c.d.example.com" |
| + |
| // deepWorld is the healthy hierarchy example.com -> d -> c -> b -> |
| -// a.b.c.d.example.com, each its own zone, the last serving deepName |
| -// pointing here. The cache also knows the last zone's NS set, as a |
| +// a.b.c.d.example.com, each its own zone, the last serving deepName and |
| +// deepGapName pointing here. The cache also knows the last zone's NS set, as a |
| // resolver that has followed the delegation would. last is its server. |
| func deepWorld(t *testing.T) (w *world, last *fakeAuthority) { |
| t.Helper() |
| @@ -680,7 +684,7 @@ func deepWorld(t *testing.T) (w *world, last *fakeAuthority) { |
| if i+1 < len(zones) { |
| fa = startAuthority(t, z, referral(zones[i+1], fmt.Sprintf("192.0.2.%d", 11+i))) |
| } else { |
| - fa = startAuthority(t, z, authoritative(aRecord(deepName+".", edgeIP))) |
| + fa = startAuthority(t, z, authoritative(aRecord(deepName+".", edgeIP), aRecord(deepGapName+".", edgeIP))) |
| last = fa |
| } |
| w.routes[addr+":53"] = fa |
| @@ -1272,3 +1276,382 @@ func TestFreshResolverForgetEndsTheBackoff(t *testing.T) { |
| t.Fatal("Resolve after Forget did not ask again") |
| } |
| } |
| + |
| +// Astra P1 on 259abef0: a published name with a label that is no zone |
| +// between it and its zone, under a delegation deeper than the top-down |
| +// walk follows. The nearest look climbs past the label (no NS set, no |
| +// cost) to the zone, as main did. A new name never climbs: the cache |
| +// hears nothing below the registrable domain. |
| +func TestFreshResolverUpgradeClimbsPastNonZoneLabels(t *testing.T) { |
| + w, last := deepWorld(t) |
| + ips, err := w.resolver(clock()).ResolveUpgrade(deepGapName) |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("ResolveUpgrade = %v, %v; want [%s] from a.b.c.d.example.com", ips, err, edgeIP) |
| + } |
| + want := "NS eu.a.b.c.d.example.com,NS " + deepGapName + ",NS a.b.c.d.example.com,HOST ns.provider.net" |
| + if got := strings.Join(w.cached, ","); got != want { |
| + t.Fatalf("cached queries = %s, want %s", got, want) |
| + } |
| + w, last = deepWorld(t) |
| + if ips, err := w.resolver(clock()).Resolve(deepGapName); err == nil { |
| + t.Fatalf("Resolve = %v, want the new name's walk refused at the referral bound", ips) |
| + } |
| + if last.queries.Load() != 0 { |
| + t.Fatal("a new name reached the zone past the referral bound") |
| + } |
| + noCachedBelow(t, w, deepGapName, "example.com") |
| +} |
| + |
| +// The climb tries at most freshMaxZones levels that have an NS set, never |
| +// the registrable domain (the walk asks it once) and never the TLD. |
| +func TestFreshResolverUpgradeClimbIsBounded(t *testing.T) { |
| + w := &world{ns: map[string][]string{"example.com": {"ns1.example.com."}}, hosts: map[string][]string{}} |
| + for _, z := range []string{"a.b.c.d.example.com", "b.c.d.example.com", "c.d.example.com", "d.example.com"} { |
| + w.ns[z] = []string{"ns.provider.net."} |
| + } |
| + if ips, err := w.resolver(clock()).ResolveUpgrade(deepName); err == nil { |
| + t.Fatalf("ResolveUpgrade = %v, want a failure: no nameserver has an address", ips) |
| + } |
| + var got []string |
| + for _, c := range w.cached { |
| + if strings.HasPrefix(c, "NS ") { |
| + got = append(got, c) |
| + } |
| + } |
| + want := "NS a.b.c.d.example.com,NS " + deepName + ",NS b.c.d.example.com,NS c.d.example.com,NS example.com" |
| + if strings.Join(got, ",") != want { |
| + t.Fatalf("cached NS queries = %s, want %s", strings.Join(got, ","), want) |
| + } |
| +} |
| + |
| +// cohost answers as ONE server holding every zone in zones, each delegated |
| +// from the one before, the way a DNS host serves a customer's zone and its |
| +// sub-zone from the same machines. Every query is answered from the |
| +// deepest zone that encloses it: SOA queries as startAuthority does, other |
| +// queries by leaf in the last zone and as NODATA with the enclosing zone's |
| +// SOA above it. It never refers. Use with startAuthority(t, "", ...). |
| +func cohost(leaf func(dnsmessage.Question, *dnsmessage.Message) bool, zones ...string) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| + return func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + qn := strings.ToLower(strings.TrimSuffix(q.Name.String(), ".")) |
| + deepest := "" |
| + for _, z := range zones { |
| + if (qn == z || strings.HasSuffix(qn, "."+z)) && len(z) > len(deepest) { |
| + deepest = z |
| + } |
| + } |
| + switch { |
| + case deepest == "": |
| + r.RCode = dnsmessage.RCodeRefused |
| + case q.Type == dnsmessage.TypeSOA && qn == deepest: |
| + r.Authoritative = true |
| + r.Answers = []dnsmessage.Resource{soaRecord(deepest)} |
| + case q.Type == dnsmessage.TypeSOA || deepest != zones[len(zones)-1]: |
| + r.Authoritative = true |
| + r.Authorities = []dnsmessage.Resource{soaRecord(deepest)} |
| + default: |
| + return leaf(q, r) |
| + } |
| + return true |
| + } |
| +} |
| + |
| +// Astra P1 on 259abef0: one server holds example.com and the delegated |
| +// eu.example.com, and answers for shop.eu.example.com from the child, with |
| +// the child's SOA. That SOA is not proof (it is not the verified zone's), |
| +// but it is a hint: the child is verified on the same server and the name |
| +// asked again under it. The cache hears nothing more. |
| +func TestFreshResolverFollowsACoHostedChildZone(t *testing.T) { |
| + const name, edge6 = "shop.eu.example.com", "2001:db8::7" |
| + for kind, tc := range map[string]struct { |
| + leaf func(dnsmessage.Question, *dnsmessage.Message) bool |
| + want string |
| + queries int32 |
| + }{ |
| + // SOA example.com, A (the hint), SOA eu.example.com, A, AAAA. |
| + "no address record": {nodata("eu.example.com"), "", 5}, |
| + // An address is an answer wherever the server keeps it: no hint. |
| + "A record": {authoritative(aRecord(name+".", edgeIP)), edgeIP, 2}, |
| + "AAAA record": {byType(nodata("eu.example.com"), authoritative(aaaaRecord(name+".", edge6))), edge6, 5}, |
| + } { |
| + t.Run(kind, func(t *testing.T) { |
| + fa := startAuthority(t, "", cohost(tc.leaf, "example.com", "eu.example.com")) |
| + w := oneZone(fa) |
| + ips, err := w.resolver(clock()).Resolve(name) |
| + if tc.want == "" { |
| + if !errors.Is(err, domains.ErrFreshNoData) { |
| + t.Fatalf("Resolve = %v, %v; want errNoData from the verified child", ips, err) |
| + } |
| + } else if err != nil || len(ips) != 1 || ips[0] != tc.want { |
| + t.Fatalf("Resolve = %v, %v; want [%s]", ips, err, tc.want) |
| + } |
| + if got := fa.queries.Load(); got != tc.queries { |
| + t.Fatalf("server got %d queries, want %d", got, tc.queries) |
| + } |
| + if got := strings.Join(w.cached, ","); got != "NS example.com,HOST ns1.example.com" { |
| + t.Fatalf("cached queries = %s; the hint must cost none", got) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// The mismatched SOA is never trusted, only followed. An owner that is not |
| +// on the name's path is no hint at all (nothing more is asked); a child |
| +// the server cannot show an SOA for is a failure; and a child the hinting |
| +// server cannot verify is looked for on the zone's other server. |
| +func TestFreshResolverCoHostedHintIsNeverTrusted(t *testing.T) { |
| + const name = "shop.eu.example.com" |
| + failure := func(t *testing.T, r *domains.FreshResolver, fa *fakeAuthority, queries int32) { |
| + t.Helper() |
| + ips, err := r.Resolve(name) |
| + if err == nil || errors.Is(err, domains.ErrFreshNoData) || isNotFoundErr(err) { |
| + t.Fatalf("Resolve = %v, %v; want a fresh failure", ips, err) |
| + } |
| + if got := fa.queries.Load(); got != queries { |
| + t.Fatalf("server got %d queries, want %d", got, queries) |
| + } |
| + if _, err := r.Resolve(name); !errors.Is(err, domains.ErrFreshBackingOff) { |
| + t.Fatalf("second Resolve = %v, want the backoff", err) |
| + } |
| + } |
| + for owner, why := range map[string]string{ |
| + "us.example.com": "a sibling of the name's path", |
| + "deep.shop.eu.example.com": "below the name", |
| + "eu.example.net": "outside the verified zone", |
| + } { |
| + t.Run("off the path: "+why, func(t *testing.T) { |
| + // The server would verify owner if asked; it must not be asked. |
| + fa := startAuthority(t, "", func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + if q.Type != dnsmessage.TypeSOA { |
| + return nodata(owner)(q, r) |
| + } |
| + r.Authoritative = true |
| + r.Answers = []dnsmessage.Resource{soaRecord(strings.TrimSuffix(q.Name.String(), "."))} |
| + return true |
| + }) |
| + w := oneZone(fa) |
| + failure(t, w.resolver(clock()), fa, 2) // SOA example.com, A |
| + noCachedBelow(t, w, name, "example.com") |
| + }) |
| + } |
| + t.Run("child not verified", func(t *testing.T) { |
| + // Holds example.com only, yet answers under eu.example.com's SOA. |
| + fa := startAuthority(t, "example.com", nodata("eu.example.com")) |
| + w := oneZone(fa) |
| + failure(t, w.resolver(clock()), fa, 3) // SOA example.com, A, SOA eu.example.com |
| + noCachedBelow(t, w, name, "example.com") |
| + }) |
| + t.Run("the zone's other server verifies it", func(t *testing.T) { |
| + liar := startAuthority(t, "example.com", nodata("eu.example.com")) |
| + both := startAuthority(t, "", cohost(authoritative(aRecord(name+".", edgeIP)), "example.com", "eu.example.com")) |
| + 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": liar, "192.0.2.2:53": both}, |
| + } |
| + ips, err := w.resolver(clock()).Resolve(name) |
| + if err != nil || len(ips) != 1 || ips[0] != edgeIP { |
| + t.Fatalf("Resolve = %v, %v; want [%s] from the server that holds the child", ips, err, edgeIP) |
| + } |
| + if liar.queries.Load() != 3 || both.queries.Load() != 2 { |
| + t.Fatalf("hinting server got %d queries and the other %d; want 3 (SOA, A, SOA of the child) and 2 (SOA of the child, A)", liar.queries.Load(), both.queries.Load()) |
| + } |
| + noCachedBelow(t, w, name, "example.com") |
| + }) |
| +} |
| + |
| +// Hints count against the referral bound: a server that keeps naming one |
| +// more child is followed freshMaxZones times and no further. |
| +func TestFreshResolverBoundsCoHostedHints(t *testing.T) { |
| + zones := []string{"example.com", "d.example.com", "c.d.example.com", "b.c.d.example.com", "a.b.c.d.example.com"} |
| + var mu sync.Mutex |
| + next := 0 |
| + var verified []string |
| + fa := startAuthority(t, "", func(q dnsmessage.Question, r *dnsmessage.Message) bool { |
| + mu.Lock() |
| + defer mu.Unlock() |
| + r.Authoritative = true |
| + if q.Type == dnsmessage.TypeSOA { |
| + zone := strings.TrimSuffix(q.Name.String(), ".") |
| + verified = append(verified, zone) |
| + r.Answers = []dnsmessage.Resource{soaRecord(zone)} |
| + return true |
| + } |
| + // Each A query is answered under the SOA of the next zone down. |
| + if next+1 < len(zones) { |
| + next++ |
| + } |
| + r.Authorities = []dnsmessage.Resource{soaRecord(zones[next])} |
| + return true |
| + }) |
| + w := oneZone(fa) |
| + if ips, err := w.resolver(clock()).Resolve(deepName); err == nil || errors.Is(err, domains.ErrFreshNoData) { |
| + t.Fatalf("Resolve = %v, %v; want hints past the bound refused", ips, err) |
| + } |
| + mu.Lock() |
| + defer mu.Unlock() |
| + if got, want := strings.Join(verified, ","), strings.Join(zones[:4], ","); got != want { |
| + t.Fatalf("zones verified = %s, want %s and no deeper", got, want) |
| + } |
| + noCachedBelow(t, w, deepName, "example.com") |
| +} |
| + |
| +const costName = "shop.c.b.a.example.com" |
| + |
| +// costWorld is the most expensive healthy-looking hierarchy the walk |
| +// follows: example.com -> a -> b.a -> c.b.a.example.com, each zone on two |
| +// servers reached in order. The FIRST server of every zone answers with |
| +// first(zone) and gets the lookup nowhere; the SECOND refers to the next |
| +// zone (one NS host, two glue addresses, so the order holds), and in the |
| +// last zone it answers like the first. The cache also knows each child's |
| +// NS set, for the published-name look. servers is every server. |
| +func costWorld(t *testing.T, first func(zone string) func(dnsmessage.Question, *dnsmessage.Message) bool) (w *world, servers []*fakeAuthority) { |
| + t.Helper() |
| + zones := []string{"example.com", "a.example.com", "b.a.example.com", "c.b.a.example.com"} |
| + addr := func(zone, server int) string { return fmt.Sprintf("192.0.2.%d", 10+2*zone+server) } |
| + w = &world{ |
| + ns: map[string][]string{"example.com": {"ns1.example.com."}}, |
| + hosts: map[string][]string{"ns1.example.com": {addr(0, 0), addr(0, 1)}}, |
| + routes: map[string]*fakeAuthority{}, |
| + } |
| + for i, z := range zones { |
| + second := first(z) |
| + if i+1 < len(zones) { |
| + child, host := zones[i+1], "ns."+zones[i+1] |
| + w.ns[child] = []string{host + "."} |
| + w.hosts[host] = []string{addr(i+1, 0), addr(i+1, 1)} |
| + second = func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.Authorities = []dnsmessage.Resource{{ |
| + Header: dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(child + "."), Type: dnsmessage.TypeNS, Class: dnsmessage.ClassINET, TTL: 300}, |
| + Body: &dnsmessage.NSResource{NS: dnsmessage.MustNewName(host + ".")}, |
| + }} |
| + r.Additionals = []dnsmessage.Resource{aRecord(host+".", addr(i+1, 0)), aRecord(host+".", addr(i+1, 1))} |
| + return true |
| + } |
| + } |
| + for n, answer := range []func(dnsmessage.Question, *dnsmessage.Message) bool{first(z), second} { |
| + fa := startAuthority(t, z, answer) |
| + w.routes[addr(i, n)+":53"] = fa |
| + servers = append(servers, fa) |
| + } |
| + } |
| + return w, servers |
| +} |
| + |
| +func exchanges(servers []*fakeAuthority) (n int32) { |
| + for _, fa := range servers { |
| + n += fa.queries.Load() |
| + } |
| + return n |
| +} |
| + |
| +// Astra P2 on 259abef0: the maxima in resolve's cost comment, counted. A |
| +// server that answers NODATA for A and then fails the AAAA exchange has |
| +// cost three exchanges before the next server is tried, in every zone. |
| +func TestFreshResolverCostOfAFailedAAAABeforeARetry(t *testing.T) { |
| + failedAAAA := func(zone string) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| + return byType(nodata(zone), func(_ dnsmessage.Question, r *dnsmessage.Message) bool { |
| + r.RCode = dnsmessage.RCodeServerFailure |
| + return true |
| + }) |
| + } |
| + t.Run("new name", func(t *testing.T) { |
| + w, servers := costWorld(t, failedAAAA) |
| + if ips, err := w.resolver(clock()).Resolve(costName); err == nil || errors.Is(err, domains.ErrFreshNoData) { |
| + t.Fatalf("Resolve = %v, %v; want a fresh failure", ips, err) |
| + } |
| + // Three zones that hand on at 3 + 2, the last at 3 + 3. |
| + if got := exchanges(servers); got != 21 { |
| + t.Fatalf("%d authoritative exchanges, want 21, the maximum for Resolve", got) |
| + } |
| + noCachedBelow(t, w, costName, "example.com") |
| + }) |
| + t.Run("published name", func(t *testing.T) { |
| + w, servers := costWorld(t, failedAAAA) |
| + if ips, err := w.resolver(clock()).ResolveUpgrade(costName); err == nil { |
| + t.Fatalf("ResolveUpgrade = %v, want a failure", ips) |
| + } |
| + // The nearest look asks c.b.a (6), b.a (5) and a (5), then the |
| + // walk's 21. Servers that answered differently each time they |
| + // were asked could make every nearest zone cost 6: 39. |
| + if got := exchanges(servers); got != 37 { |
| + t.Fatalf("%d authoritative exchanges, want 37 (16 nearest, 21 walk)", got) |
| + } |
| + }) |
| +} |
| + |
| +// The other maximum: a reply ending in an out-of-zone CNAME target sends |
| +// the target to the cache, and when that lookup fails the next server is |
| +// tried, which may send it again. |
| +func TestFreshResolverCostOfAFailedCNAMELookupBeforeARetry(t *testing.T) { |
| + const target = "edge.provider.net" |
| + w, servers := costWorld(t, func(string) func(dnsmessage.Question, *dnsmessage.Message) bool { |
| + return authoritative(cnameRecord(costName+".", target+".")) |
| + }) |
| + r := w.resolver(clock()) |
| + lookupHost := r.LookupHost |
| + r.LookupHost = func(ctx context.Context, host string) ([]string, error) { |
| + if host == target { |
| + w.note("HOST", host) |
| + return nil, errors.New("server misbehaving") |
| + } |
| + return lookupHost(ctx, host) |
| + } |
| + if ips, err := r.Resolve(costName); err == nil || isNotFoundErr(err) { |
| + t.Fatalf("Resolve = %v, %v; want a fresh failure", ips, err) |
| + } |
| + // One in each zone that hands on, two in the last. |
| + if got := w.cachedFor(target); got != 5 { |
| + t.Fatalf("%d cached lookups of the CNAME target, want 5", got) |
| + } |
| + // SOA and A from both servers of all four zones. |
| + if got := exchanges(servers); got != 16 { |
| + t.Fatalf("%d authoritative exchanges, want 16", got) |
| + } |
| + noCachedBelow(t, w, costName, "example.com") |
| +} |
| + |
| +// Astra P2 on 259abef0: Retain gives back what removed names hold. A |
| +// strike map full of pending strikes for names the deployment no longer |
| +// carries is emptied of them, a name still carried keeps its pending |
| +// strike, and the next new failure is held again instead of counting as |
| +// the second strike. |
| +func TestFreshResolverRetainReclaimsRemovedNames(t *testing.T) { |
| + r := &domains.FreshResolver{} |
| + r.Strike("shop.example.com") |
| + for i := 0; i < 2*domains.FreshMaxBackoff; i++ { |
| + r.Strike(fmt.Sprintf("n%d.example.com", i)) |
| + } |
| + if !r.Strike("late.example.com") { |
| + t.Fatal("fixture: the map is not full of pending strikes") |
| + } |
| + r.Retain([]string{"Shop.Example.com.", "late.example.com"}) |
| + if got := domains.FreshStrikeState(r, "n7.example.com"); got != 0 { |
| + t.Fatalf("removed name's strike state = %d, want 0 (reclaimed)", got) |
| + } |
| + if r.Strike("late.example.com") { |
| + t.Fatal("a new failure after the reclaim counted as the second strike; want it held") |
| + } |
| + if !r.Strike("shop.example.com") { |
| + t.Fatal("Retain forgot the pending strike of a name still present") |
| + } |
| +} |
| + |
| +// Retain drops a removed name's failure backoff too, and keeps a present |
| +// name's. |
| +func TestFreshResolverRetainPrunesTheBackoff(t *testing.T) { |
| + fa := startAuthority(t, "example.com", nil) |
| + r := oneZone(fa).resolver(clock()) |
| + r.Timeout, r.AttemptTimeout = 100*time.Millisecond, 50*time.Millisecond |
| + if _, err := r.Resolve("shop.example.com"); err == nil { |
| + t.Fatal("Resolve against a silent server succeeded") |
| + } |
| + sent := fa.queries.Load() |
| + r.Retain([]string{"shop.example.com"}) |
| + if _, err := r.Resolve("shop.example.com"); !errors.Is(err, domains.ErrFreshBackingOff) || fa.queries.Load() != sent { |
| + t.Fatalf("Resolve after Retain kept the name = %v, want the backoff", err) |
| + } |
| + r.Retain([]string{"other.example.com"}) |
| + if _, err := r.Resolve("shop.example.com"); errors.Is(err, domains.ErrFreshBackingOff) || fa.queries.Load() == sent { |
| + t.Fatalf("Resolve after Retain dropped the name = %v, want a real lookup", err) |
| + } |
| +} |
diff --git a/internal/domains/reconcile.go b/internal/domains/reconcile.go| index 72fd69d7e..540659ebf 100644 |
| --- a/internal/domains/reconcile.go |
| +++ b/internal/domains/reconcile.go |
| @@ -47,7 +47,7 @@ type Config struct { |
| // leaves every verdict to Resolve alone. |
| ResolveFresh func(host string) ([]string, error) |
| // ResolveUpgrade is the fresh look for a published name's upgrade: the |
| - // name's nearest zone first, then ResolveFresh's walk (FreshResolver's |
| + // name's nearest zones 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 |
| @@ -58,6 +58,10 @@ type Config struct { |
| // new name whose fresh look failed (see dnsVerdicts). nil takes the |
| // cached look on the first failure. |
| FreshStrike func(host string) (second bool) |
| + // FreshRetain is the same resolver's Retain: dnsVerdicts hands it the |
| + // pass's hostnames, so the resolver drops what it remembers about |
| + // names the deployment no longer carries. nil skips that. |
| + FreshRetain func(hosts []string) |
| // AcmeDir is the edge's autocert DirCache directory; "" skips TLS |
| // stamping entirely. |
| AcmeDir string |
| @@ -634,6 +638,11 @@ var ( |
| // 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. |
| +// |
| +// The pass's hostnames go to cfg.FreshRetain first: these are every route |
| +// and alias the box carries, so whatever the resolver remembers about any |
| +// other name (a failure backoff, a pending strike) belongs to a name that |
| +// has been removed, and is dropped. |
| func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) { |
| key := func(host string) string { return strings.ToLower(strings.TrimSuffix(host, ".")) } |
| var hosts []freshCandidate |
| @@ -652,6 +661,13 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) |
| hosts[i].checked = c.checked |
| } |
| } |
| + if cfg.FreshRetain != nil { |
| + names := make([]string, len(hosts)) |
| + for i, h := range hosts { |
| + names[i] = h.host |
| + } |
| + cfg.FreshRetain(names) |
| + } |
| hostVerdicts(cfg, edge, hosts) |
| for _, c := range candidates { |
| *c.status = *hosts[at[key(c.host)]].status |
| @@ -687,8 +703,8 @@ func dnsVerdicts(cfg Config, edge map[string]bool, candidates []freshCandidate) |
| // 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: 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 |
| +// nearest zones first, as on main, then top-down from the registrable |
| +// domain if they give 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. |
| // |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index dce3bcc75..4803d52fd 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -3828,7 +3828,8 @@ func domainsTickConfig(getenv func(string) string, publicIP string) (domains.Con |
| // 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. |
| + // name's nearest zones. Each pass tells the resolver which names are |
| + // still carried (FreshRetain), so it forgets the rest. |
| fresh := &domains.FreshResolver{ |
| LookupNS: net.DefaultResolver.LookupNS, |
| LookupHost: net.DefaultResolver.LookupHost, |
| @@ -3837,6 +3838,7 @@ func domainsTickConfig(getenv func(string) string, publicIP string) (domains.Con |
| cfg.ResolveUpgrade = fresh.ResolveUpgrade |
| cfg.FreshForget = fresh.Forget |
| cfg.FreshStrike = fresh.Strike |
| + cfg.FreshRetain = fresh.Retain |
| // EdgeIPs is deliberately left nil here — a Config out of this function |
| // alone stamps nothing. domainsLoop installs the fold once it has a |
| // store; see the doc comment. |
diff --git a/internal/host/host_test.go b/internal/host/host_test.go| index ec6809bdb..f1a3b8b89 100644 |
| --- a/internal/host/host_test.go |
| +++ b/internal/host/host_test.go |
| @@ -772,8 +772,8 @@ func TestDomainsTickConfig(t *testing.T) { |
| } |
| // #724: the uncached second look for a customer's hostname is wired in |
| // production, not only in the domains tests. |
| - if got.ResolveFresh == nil || got.ResolveUpgrade == nil || got.FreshForget == nil || got.FreshStrike == nil { |
| - t.Error("ResolveFresh/ResolveUpgrade/FreshForget/FreshStrike not populated on a configured deployment") |
| + if got.ResolveFresh == nil || got.ResolveUpgrade == nil || got.FreshForget == nil || got.FreshStrike == nil || got.FreshRetain == nil { |
| + t.Error("ResolveFresh/ResolveUpgrade/FreshForget/FreshStrike/FreshRetain not populated on a configured deployment") |
| } |
| // No explicit edge IPs: the box's own public IP (IMDS) is the default. |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 6ef423ee4..9a0f61521 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 9d87c4c63726a6f840f22fe624edd90e1071d06d0af7ab87d895ecf64bf6551e |
| +plan14-root-reads-no-negative-prime-724.tsv ab10145ee873e26b87a653f728cd0c9737592fefe94b659ac5988201c195cb7a |
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 e8278e95e..8dab61aa7 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 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 |
| +@legacy c27819c501ee7be78b134989641e2c5d8f2ad104ee72892d8fa0552392a7f7ee 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 five of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: for names already "pointing" only, asks the name's nearest zones first, climbing its levels below the registrable domain through cached NS sets, at most three levels that have one, and then the same top-down walk), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host), Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure) and Retain (new FreshRetain, drops that resolver's in-memory backoff and strike entries for names not in the pass's route and alias hostnames; it only deletes map entries, sends and reads nothing); 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 4c595e5641a0d9fd91b111f354639adaed399158fe1871cbf7373eebada4a6f8 |
| +@legacy dcbe7775e0b06683acd3bbc80dc58256a17cb8b2124153bb4dbaf2246923fe81 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; an authoritative empty reply under the SOA of a child zone on the name's path is only a hint to verify that child by its own SOA on the same already-public servers and ask again, never an answer). 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 4dfdb094052ad77607f1975bca6537ed46fe8d057e53c36d1469bd8ac0d11a04 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 first hands the pass's hostnames to Config.FreshRetain (the resolver forgets its in-memory backoff and strike for names no longer carried) and then 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 zones 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 five of its methods into domains.Config: Resolve (ResolveFresh), ResolveUpgrade (new: for names already "pointing" only, asks the name's nearest zones first, climbing its levels below the registrable domain through cached NS sets, at most three levels that have one, and then the same top-down walk), Forget (FreshForget, clears that resolver's in-memory backoff and strike for a host), Strike (new FreshStrike, the in-memory two-strike rule for a new name's fresh failure) and Retain (new FreshRetain, drops that resolver's in-memory backoff and strike entries for names not in the pass's route and alias hostnames; it only deletes map entries, sends and reads nothing); 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 4c595e5641a0d9fd91b111f354639adaed399158fe1871cbf7373eebada4a6f8 |
| +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; an authoritative empty reply under the SOA of a child zone on the name's path is only a hint to verify that child by its own SOA on the same already-public servers and ask again, never an answer). 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 first hands the pass's hostnames to Config.FreshRetain (the resolver forgets its in-memory backoff and strike for names no longer carried) and then 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 zones 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 8aebb158aa7dcb47989ef8e1b8a0bab0226c31d3095ea4803a117f48367943d2 |
| -@coverage internal/host 306615a57fb5b2b3bf94cce44950726cad083d72c4e5c6e3aea569148710a392 |
| +@coverage internal/domains 2370e0f17ba78af0e6fb455605a834281f9275c68da1847b86ad601d150792f4 |
| +@coverage internal/host ce3ebe4a23d41ff37ce18672099a3810530e5e565b2d062e0347ffb99d3ba404 |