Merge branch 'warm-set-published-724' into main
certwarm: warm only custom names their home box published pointing (#724) The cert issuer took a newly attached alias into its warm set from the local route table, before any DNS stamp, so its cached gate lookup planted a negative entry for the name while the record did not exist yet. The edges file now carries an additive dns_pointing mark per custom host; the home map exposes this box's own published pointing names; the warm set reads publication instead of the route table (regional names excepted). A name published not pointing is neither ordered nor re-armed by the warm; its cached certificate keeps serving and re-arms on a handshake. DNS-miss entries are retired when a name leaves the set; the pass reads the set only after the issuer gate; failure records are kept while any box publishes the exact name. Built by Claude Fable 5.2; reviewed by Astra (five rounds); census approved by Astra on #280.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
13 files changed,
+1,232
−71
docs/superpowers/notes/census-proposal-warm-set-published-724.md+21 −0internal/edge/certwarm.go+182 −28internal/edge/certwarm_test.go+507 −14internal/edge/edge.go+3 −13internal/edge/homemap.go+130 −13internal/edge/homemap_dnspointing_test.go+118 −0internal/edgesfile/dnspointing_test.go+33 −0internal/edgesfile/edgesfile.go+23 −0internal/host/edgesfile.go+36 −1internal/host/edgesfile_dnspointing_test.go+168 −0internal/host/group_names_test.go+2 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-warm-set-published-724.tsv+8 −0
CI failed — run details
diff --git a/docs/superpowers/notes/census-proposal-warm-set-published-724.md b/docs/superpowers/notes/census-proposal-warm-set-published-724.md| new file mode 100644 |
| index 000000000..c4b9db0f1 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-warm-set-published-724.md |
| @@ -0,0 +1,21 @@ |
| +# Census approval: warm-set-published-724 |
| + |
| +Ruling `census-ruling-warm-set-published-724`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/edge/edge.go` `RunWithActivatorReady` | body | unchanged (5) | #724: the inline cert warm construction (newCertWarm over warmSet and dnsGate, then OnReload and setServedWake registering warm.nudge) moves unchanged into the new Edge.newIssuerWarm in certwarm.go and is called here with the same apps domain, parents, perHostCert, warmResolver, edgeIPs and store; the loop still starts here. The warm set it wires now reads the published edges files through the home map (OwnServedHosts and ServedHosts, both already polled) instead of the local route table, regional names aside. It is a different source, not a subset: an attached name not yet published as pointing is no longer listed, while a name the route table has already dropped stays listed until this box's next edges file write and the home map's next poll catch up (HostPolicy still refuses an order for a name the registry no longer holds). A name published not pointing is not a warm candidate at all, whether or not its certificate is cached: the warm neither looks it up, orders it nor re-arms its renewal until its home box publishes it pointing again (a cached certificate keeps serving and re-arms on a handshake at the issuer). The warm reads the set only after the issuer gate, and the read is in memory (route table and the home map's last snapshot); it also drops a DNS-miss entry for a name that has left the set before probing it. It keeps a failure record while any box publishes the exact name (the home map DeployedHosts: every box's file, own included, pointing or not, the same in-memory snapshot) or the name is a regional route-table name, and prunes it only once no box publishes it. That retention set has no apps-domain or wildcard filter (those stay on candidacy only), so a name published not pointing, or one a wildcard parent starts covering, keeps the record that explains its backoff; the set is never a source of candidates. No read site added in this unit, same 5 sites. | |
| +| `internal/host/edgesfile.go` `edgesFileWriteClaims` | sites | +registry:Alias, +registry:DNSStatus, +registry:Host | #724: the agent as carlos: reads PLATFORM_APPS_DOMAIN from the environment once per pass (the variable domainsLoop already reads) and sets an additive dns_pointing mark on each published custom name through dnsPointingMark: true on a published alias (registry:Alias, already published only when its dns_status is pointing), and on a route with a hostname outside the apps domain whether its registry:DNSStatus is pointing (registry:Host, registry:DNSStatus on rows the pass already lists). No mark under the apps domain, on a wildcard row, or with no apps domain set. A report the issuer cert warm reads to leave a not-yet-pointing custom name out of its set, not a root decision; it publishes the same names as before. No record, /data, release or claim read added; no new registry query; F,J1 authority retained. One-off cost: the first pass after the upgrade writes once on a box homing a custom name. | |
| + |
| +Envelopes re-pinned: `internal/edge`, `internal/edgesfile`, `internal/host`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/edge/edge.go` `RunWithActivatorReady`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Wrap dev, HTTP and HTTPS listeners through ConfigureGroupHairpin before serving. Indirectly read protected root boot identity and group-ingress.json; kernel local/peer addresses mark local ingress, never HTTP headers. Agent edge uses verified public source for accounting; direct read sites unchanged and absent marker keeps original listeners. CI fix removes interface enumeration: local peer must match snapshot primary IPv4, an ingress IPv4 installed locally by root, or loopback; kernel destination must still be an ingress EIP on port 80/443. Merge 45cebde4 retains deferred stopReplicaProbes alongside group listener wrapping and shutdown admission closure.;rev3=census-ruling-demo-api-site-route;basis=Change the startup failure context from load routes to initialize because origin validation now runs during construction. Existing five read sites unchanged; no new read or runtime authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Invoke the agent shutdown timestamp hook synchronously at SIGTERM/SIGINT receipt before closing admission in dev and TLS paths. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: registers the https and http servers with the connection drain (conns.serve) so a drain can close idle keep-alive connections; no read added |
| +- `internal/host/edgesfile.go` `edgesFileWriteClaims`: authority, task F,J1. Basis: rev3=census-ruling-self-serve-moves-1;basis=root-route;kept=F;scope=protected-decision-only; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): region-ha-2a's body, which with the box's lifetimes switch on also publishes each served row's lifetime pair (registry:Incarnation and registry:ServingSeq, two new sites on the rows it already lists) and an alias's or served catch-all's primary's pair, and names that primary as target_host whatever the switch; a report the edge orders unstamped entries by, not a decision; no record, /data, release or claim read added; F,J1 authority retained; self-serve moves 1 Task 8;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 8: takes a localAddrs reader (instancectl.LocalAddresses in production, which reads /proc/net/fib_trie and /proc/net/if_inet6 in the agent) and publishes its non-loopback entries as the edges file's addrs before the write gate (boxAddrs, no read of its own), so an address change writes once. The same 44 sites, offsets moved; no record, /data, release or claim read added; a report the console's egress grant check reads, not a root decision; F,J1 authority retained.;rev3=census-ruling-edge-asset-cache-3;basis=starts with assets = assets.active(), so a policy whose box has not opened its asset store publishes no assets blocks and reads no manifests, and copies the decision's Primary (the route host the block was decided for, drift D4) into the published assets block; read sites unchanged (44); no read added. Merged onto main's #328 body, which takes the localAddrs reader: the assets.active() line sits after that signature and the loop passes pub and instancectl.LocalAddresses;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the claims argument (*edgesClaims) becomes addrs (AddressSource) and the applyEdgesClaims(ctx, claims, routes, hosts) call is deleted with edgesclaims.go, which is the one whole:Route site removed: no host claim is read and every served row publishes as with region HA off; the box-address publication is the same code reading addrs.BoxAddresses() instead of claims.addrs; a report the edge reads, not a root decision; no read added; merge of origin/main d7ae1d76: main's edge asset cache plan 3 body is kept (census-ruling-edge-asset-cache-3): the first line is assets = assets.active(), so a policy whose store has not opened publishes no assets blocks and reads no manifests, and edgesFileLoop passes pub (assets.active() for that tick) in the assets argument; main's claims *edgesClaims argument is this branch's addrs AddressSource, and no edgesClaims, applyEdgesClaims or hostclaim reference remains;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: skips publishing a platform alias edge.PlatformAliasFold refuses (and so anything attached to it); reads the same route listing;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 and its fix rounds: publishes by FleetArmVerdict (via fleetRefusedFor): withheld rows left out; a forward host's path rows left out of its owner; no assets for forward rows; the alias loop replays Reload's alias fold from the served rows so a chained alias carries its root primary's owner; certRefused and parentRefused leave out a refused claim's wildcard parent (+registry:Alias x5, +registry:Host x4, +whole:Route, +whole:RouteAlias x2, +whole:RoutePath x7, +whole:WildcardDomain). Rows already read in the pass; keeps authority F,J1; publishes less, never more.;rev3=census-ruling-probe-burst-limit;basis=sets the constant BurstNotices=true on the box's own edges file (this build's edge answers probe-burst notices, so peers may send them); not from config or any read; the same 65 sites; a report other edges read, not a root decision; F,J1 authority retained; no new root read or write kind;rev3=census-ruling-region-ha-p3a;basis=Publish one injected role snapshot with box_role/admitted/drained; retain legacy route and alias rows during booting, cutting namespace withdrawal under the 2026-11-04 ruling; acknowledge the exact published tuple only after PUT; existing registry reads unchanged.;rev3=census-ruling-region-ha-p2b;basis=region HA P2b-1 T0 (Q1 ruling): before building the comparison copy and the body, a nil NamedPools on the identity becomes []string{} so the additive named_pools field is always an explicit array; the list itself is computed once at arm by edgesFileEligibility from the same provisionTickConfig(os.Getenv) parse as serves_shared_pool (CARLOS_POOLS through provision.ParseBoxPools, filtered to nonempty provision.ValidPool names, sorted, unique). A report the console reads for create admission, not a root decision; no record, /data, release or claim read added; read sites unchanged (65); F,J1 authority retained. One-off cost: the first pass after the upgrade writes once per box (seeded gate null vs []).;rev3=census-ruling-region-ha-p3b;basis=Require cached GroupReadersReady before first group publication and append additive names-2 capability even for supplied identities. Agent writes the same edges object/index with existing registry reads; known readers come from root boot configuration, snapshot from existing fold, no added GET/LIST or root authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Omit non-forward, non-platform-alias rows outside local served pools from home publication; added Host/Pool field reads and local configuration use, existing registry/store operations retained.;rev3=census-ruling-edge-page-cache-1;basis=prunes the manifest cache through the new atomic pointer (assets.manifests.Load().prune(...), nil-safe); nothing else changes; read sites unchanged (67); no read added;rev3=census-ruling-region-ha-held-build;basis=writes also when DrainPublishRequired, and reports the written drain state, its ha_drain mark (transaction and publication id) and generation to DrainSource (in-memory); the file gains ha_drained and ha_drain beside the existing draining; no read added. held-requests Task 4: sets the constant ha_take=1 on the box's own file when its in-memory capabilities include region-ha-1 (this build's edge answers take requests); not from config or any read; a report other edges read, not a root decision; no read added |
| + |
| +Seal: `9668105384b1abd5009d76a73e37eef7f5c358eb5b08a3d1fe35f7c411e4d200` → `158a30344d45448de74c9d6fbcc46eeab1ef76980c17a6baef3bb36e38cac00c`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-warm-set-published-724.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/edge/certwarm.go b/internal/edge/certwarm.go| index 789903d3e..374d96e62 100644 |
| --- a/internal/edge/certwarm.go |
| +++ b/internal/edge/certwarm.go |
| @@ -125,6 +125,13 @@ type certWarm struct { |
| // not under the apps domain and not covered by a wildcard. See |
| // Edge.warmSet. |
| hosts func() []string |
| + // deployed, when set, lists the names still attached to this deployment |
| + // whether or not they are warm candidates, with none of the warm set's |
| + // filters applied (Edge.warmDeployed). Only the |
| + // record prune reads it: a failure record outlives its name leaving the |
| + // warm set for as long as the name is still deployed. Nil means the warm |
| + // set is all there is. |
| + deployed func() []string |
| // getCert is autocert's per-host path (NOT the wildcard-wrapped one — a |
| // wrapped call would be answered by the wildcard and order nothing). |
| getCert func(*tls.ClientHelloInfo) (*tls.Certificate, error) |
| @@ -150,7 +157,9 @@ type certWarm struct { |
| warmed map[string]bool |
| // dnsMisses is the DNS-miss schedule: each never-warmed host that has |
| // failed the DNS gate, with when it first did and when to look again. |
| - // Cleared when the host's order goes out and pruned with the set. |
| + // An entry is retired when the host's order goes out, when the host is |
| + // re-armed as already warmed, and when the host leaves the set |
| + // (retireDNSMisses): a name no longer in the set is never looked up. |
| dnsMisses map[string]dnsMiss |
| // recentOrders stamps the new orders placed in the last warmCappedDelay, |
| // the window warmOrdersPerPass is counted over. |
| @@ -401,6 +410,10 @@ func (c *certWarm) probeDNS() bool { |
| if !c.isIssuer() { |
| return false |
| } |
| + // A name that has left the set since the last pass is retired here, not |
| + // looked up: its home box may have just published it as not pointing |
| + // (#724), and the next full pass can be an hour away. |
| + c.retireDNSMisses(hostSet(c.hosts())) |
| now := c.now() |
| c.mu.Lock() |
| var due []string |
| @@ -421,6 +434,28 @@ func (c *certWarm) probeDNS() bool { |
| return points |
| } |
| +// hostSet is hosts as a membership set. |
| +func hostSet(hosts []string) map[string]bool { |
| + set := make(map[string]bool, len(hosts)) |
| + for _, h := range hosts { |
| + set[h] = true |
| + } |
| + return set |
| +} |
| + |
| +// retireDNSMisses drops every DNS-miss entry whose host is not in inSet, the |
| +// warm set as the caller has just read it. The schedule exists to look a |
| +// name up again, and only a name in the set may be looked up. |
| +func (c *certWarm) retireDNSMisses(inSet map[string]bool) { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + for h := range c.dnsMisses { |
| + if !inSet[h] { |
| + delete(c.dnsMisses, h) |
| + } |
| + } |
| +} |
| + |
| // orderBudget is how many new orders the window still allows, after |
| // forgetting the stamps that have left it. |
| func (c *certWarm) orderBudget(now time.Time) int { |
| @@ -438,18 +473,20 @@ func (c *certWarm) orderBudget(now time.Time) int { |
| // pass warms every host in the set once and returns how long to wait. |
| func (c *certWarm) pass() time.Duration { |
| - hosts := c.hosts() |
| // Stand down before ANY work: unlike the wildcard manager there is no |
| - // cache to load first, so a non-issuer has nothing useful to do here. |
| - // The gate comes BEFORE the empty-set check, not after, because the |
| - // sweep at the bottom of this pass has work to do in a deployment with |
| - // no custom domains at all — spent challenge tokens and long-expired |
| - // certs are not the warm set's business. |
| + // cache to load first, so a non-issuer has nothing useful to do here, |
| + // not even reading the set. The gate comes BEFORE the empty-set check, |
| + // not after, because the sweep at the bottom of this pass has work to |
| + // do in a deployment with no custom domains at all: spent challenge |
| + // tokens and long-expired certs are not the warm set's business. |
| ctx, ok := c.issuerGate() |
| if !ok { |
| - c.logStandDown(len(hosts)) |
| + c.logStandDown(-1) |
| return warmInterval |
| } |
| + // The set is read once, after the gate, and it is an in-memory read: |
| + // the route table and the home map's last snapshot (Edge.warmSet). |
| + hosts := c.hosts() |
| if len(hosts) == 0 { |
| c.mu.Lock() |
| clear(c.dnsMisses) |
| @@ -464,10 +501,7 @@ func (c *certWarm) pass() time.Duration { |
| // that currently HAVE a record, which is what makes both the |
| // delete-on-success and the prune below decidable without a Get per host. |
| records := c.loadRecords(ctx) |
| - inSet := make(map[string]bool, len(hosts)) |
| - for _, h := range hosts { |
| - inSet[h] = true |
| - } |
| + inSet := hostSet(hosts) |
| orders, capped := 0, false |
| budget := c.orderBudget(c.now()) |
| for _, h := range hosts { |
| @@ -475,6 +509,10 @@ func (c *certWarm) pass() time.Duration { |
| c.mu.Lock() |
| until, backing := c.nextAttempt[h] |
| seen := c.warmed[h] |
| + if seen { |
| + // A warmed host has no first order left to wait for DNS on. |
| + delete(c.dnsMisses, h) |
| + } |
| c.mu.Unlock() |
| if backing && now.Before(until) { |
| continue |
| @@ -551,14 +589,8 @@ func (c *certWarm) pass() time.Duration { |
| delete(records, h) |
| } |
| } |
| - c.prune(ctx, records, inSet) |
| - c.mu.Lock() |
| - for h := range c.dnsMisses { |
| - if !inSet[h] { |
| - delete(c.dnsMisses, h) |
| - } |
| - } |
| - c.mu.Unlock() |
| + c.prune(ctx, records, c.stillDeployed(inSet)) |
| + c.retireDNSMisses(inSet) |
| owed, isOwed := c.owedWait(inSet) |
| // Housekeeping last: it is the least urgent thing this pass does, and |
| // running it after the orders means a slow bucket delays litter removal |
| @@ -646,6 +678,11 @@ func (c *certWarm) logStandDown(hosts int) { |
| return |
| } |
| c.lastStandDownLog = time.Now() |
| + if hosts < 0 { |
| + // Stood down before the set was read (pass's first gate). |
| + log.Printf("edge: cert warm standing down: another box holds the issuer lease") |
| + return |
| + } |
| log.Printf("edge: cert warm standing down for %d host(s) — another box holds the issuer lease", hosts) |
| } |
| @@ -682,6 +719,34 @@ func warmHello(host string) *tls.ClientHelloInfo { |
| // alias, so an alias-only rule would silently never warm the shipped headline |
| // flow. |
| // |
| +// What follows from that for a name published NOT pointing (#724): it is not |
| +// a warm candidate at all. The warm neither orders it nor re-arms its |
| +// renewal, and never looks it up. A certificate already cached for it keeps |
| +// serving, and its renewal is re-armed by the first handshake for it that |
| +// reaches the issuer. When its home box publishes it pointing again the |
| +// warm re-arms it on the next pass. There is deliberately no "cached |
| +// certificate" exception: whether autocert would renew an entry or mint a |
| +// new one cannot be decided from outside autocert, and a wrong guess is an |
| +// order with no DNS gate in front of it. |
| +// |
| +// Where the names come from, and where they deliberately do not (#724): the |
| +// PUBLISHED edges files, through the home map. OwnServedHosts is this box's |
| +// own file and ServedHosts is every other box's, and both leave out a custom |
| +// name its home box has not yet stamped "pointing". This box's route table |
| +// (e.current()) is no longer the source for its own names. It gains an |
| +// alias the moment the alias is attached, before the customer's DNS record |
| +// need exist, and every name in this set is looked up through the box's |
| +// caching resolver (dnsGate): a lookup made that early plants "no such name" |
| +// in the cache for the zone's negative TTL, and the certificate then waits |
| +// that long after the record appears instead of about a minute. Reading the |
| +// publication instead means the issuer's FIRST lookup of a new custom name |
| +// comes after its home box has seen the record. |
| +// |
| +// The one thing still read from the route table is a regional name |
| +// (regional.go, #447): no box publishes those in its edges file, so the |
| +// table is the only place the regional apex exists. They are written by the |
| +// platform from a regional claim, not attached by a tenant ahead of DNS. |
| +// |
| // What it excludes, and why each one: |
| // |
| // - "*." rows — covered by a wildcard PEM, and autocert refuses the |
| @@ -697,6 +762,48 @@ func warmHello(host string) *tls.ClientHelloInfo { |
| // test would warm every app of a new account per-host during exactly the |
| // window before their wildcard lands. |
| func (e *Edge) warmSet(appsDomain string, parents func() []string) []string { |
| + homes := e.homes.Load() |
| + return e.warmNames(appsDomain, parents, homes.OwnServedHosts(), homes.ServedHosts()) |
| +} |
| + |
| +// warmDeployed is the names still attached to this deployment, whether or |
| +// not they are warm candidates: every exact name some box publishes, this |
| +// box included, pointing or not (homeMap.DeployedHosts), and the regional |
| +// names in the route table. The warm prunes failure records against it and |
| +// uses it for nothing else; it is never a source of candidates. |
| +// |
| +// It deliberately applies NONE of warmSet's filters. Those decide whether a |
| +// name may be ordered; this decides whether a name is still attached. A |
| +// rate-limited name that a wildcard parent starts covering leaves the warm |
| +// set but keeps its backoff (nextAttempt), and if the cover is withdrawn |
| +// inside that backoff the name waits it out: the record that explains the |
| +// wait has to be there still (#724). |
| +func (e *Edge) warmDeployed() []string { |
| + seen := map[string]bool{} |
| + var out []string |
| + add := func(h string) { |
| + h = strings.ToLower(strings.TrimSpace(h)) |
| + if h == "" || seen[h] { |
| + return |
| + } |
| + seen[h] = true |
| + out = append(out, h) |
| + } |
| + for h, up := range e.current() { |
| + if up.regional != regionalNone { |
| + add(h) |
| + } |
| + } |
| + for _, h := range e.homes.Load().DeployedHosts() { |
| + add(h) |
| + } |
| + sort.Strings(out) |
| + return out |
| +} |
| + |
| +// warmNames applies warmSet's filters to the regional names in the route |
| +// table and to the published name lists given. |
| +func (e *Edge) warmNames(appsDomain string, parents func() []string, published ...[]string) []string { |
| appsDomain = strings.ToLower(strings.TrimSpace(appsDomain)) |
| covered := wildcardCoverer(parents) |
| seen := map[string]bool{} |
| @@ -715,16 +822,45 @@ func (e *Edge) warmSet(appsDomain string, parents func() []string) []string { |
| seen[h] = true |
| out = append(out, h) |
| } |
| - for h := range e.current() { |
| - consider(h) |
| + for h, up := range e.current() { |
| + if up.regional != regionalNone { |
| + consider(h) |
| + } |
| } |
| - for _, h := range e.homes.Load().ServedHosts() { |
| - consider(h) |
| + for _, list := range published { |
| + for _, h := range list { |
| + consider(h) |
| + } |
| } |
| sort.Strings(out) |
| return out |
| } |
| +// newIssuerWarm builds this edge's cert warm and wires its two wakes. It is |
| +// the whole of the production wiring, so a test that calls it exercises the |
| +// same set, gate and wakes the edge runs with: the set is warmSet, the DNS |
| +// gate is dnsGate over resolve and edgeIPs, and the warm is nudged by a |
| +// local route reload and by a change in either half of the published name |
| +// set (homeMap.setServedWake). The caller starts the loop. |
| +func (e *Edge) newIssuerWarm(appsDomain string, parents func() []string, getCert func(*tls.ClientHelloInfo) (*tls.Certificate, error), resolve func(string) ([]string, error), edgeIPs func() []string, store release.Store) *certWarm { |
| + warm := newCertWarm( |
| + func() []string { return e.warmSet(appsDomain, parents) }, |
| + getCert, |
| + dnsGate(resolve, edgeIPs), |
| + e.issuerGate, |
| + store, |
| + ) |
| + warm.deployed = e.warmDeployed |
| + // Woken when its set may have grown (#386), so a custom domain is |
| + // ordered seconds after it is published rather than at the next hourly |
| + // pass: a change in the names this box or another publishes (#724), or a |
| + // local route reload (a regional name). A wake with nothing new in the |
| + // set is dropped. |
| + e.OnReload(warm.nudge) |
| + e.homes.Load().setServedWake(warm.nudge) |
| + return warm |
| +} |
| + |
| // wildcardCoverer reports whether a host is exactly one label under a |
| // wildcard parent this box has configured or derived — by SHAPE, never by |
| // whether the parent's cert exists yet (see warmSet). A nil parents func |
| @@ -915,8 +1051,26 @@ func (c *certWarm) clearRecord(ctx context.Context, host, why string) { |
| log.Printf("edge: cert warm: cleared the outcome record for %s (%s)", host, why) |
| } |
| -// prune drops records for hosts that are no longer in the warm set — a |
| -// detached custom domain, or one whose route went away. |
| +// stillDeployed is the set prune keeps records for: the warm set plus every |
| +// name still deployed (c.deployed). An in-memory read, like the set itself. |
| +func (c *certWarm) stillDeployed(inSet map[string]bool) map[string]bool { |
| + if c.deployed == nil { |
| + return inSet |
| + } |
| + keep := hostSet(c.deployed()) |
| + for h := range inSet { |
| + keep[h] = true |
| + } |
| + return keep |
| +} |
| + |
| +// prune drops records for hosts that are no longer deployed: a detached |
| +// custom domain, or one whose route went away. keep is stillDeployed's |
| +// answer, not the warm set. A name its home box publishes not pointing has |
| +// left the warm set but is still attached, and its backoff (nextAttempt) |
| +// outlives its time out of the set; dropping the record there would leave |
| +// the wait in force with nothing to explain it, and lose the attempt count |
| +// (#724). |
| // |
| // This deliberately DOES delete on the strength of an inference ("not in the |
| // set"), which §3f forbids for certificates. The distinction is ownership, |
| @@ -926,12 +1080,12 @@ func (c *certWarm) clearRecord(ctx context.Context, host, why string) { |
| // the next failure rebuilds. The prune is also fenced by pass()'s early |
| // return on an empty set, so the one case that would delete EVERYTHING — |
| // a warm set that briefly folds to nothing — never reaches here. |
| -func (c *certWarm) prune(ctx context.Context, records map[string]certwarm.Record, inSet map[string]bool) { |
| +func (c *certWarm) prune(ctx context.Context, records map[string]certwarm.Record, keep map[string]bool) { |
| if c.store == nil || len(records) == 0 { |
| return |
| } |
| for host := range records { |
| - if inSet[host] { |
| + if keep[host] { |
| continue |
| } |
| c.clearRecord(ctx, host, "detached") |
diff --git a/internal/edge/certwarm_test.go b/internal/edge/certwarm_test.go| index 26b4d8160..80a4388e8 100644 |
| --- a/internal/edge/certwarm_test.go |
| +++ b/internal/edge/certwarm_test.go |
| @@ -5,6 +5,7 @@ import ( |
| "crypto/tls" |
| "errors" |
| "os" |
| + "slices" |
| "strings" |
| "sync" |
| "testing" |
| @@ -42,20 +43,36 @@ func TestWarmHelloCarriesTheServerName(t *testing.T) { |
| } |
| } |
| +// publishedEdge is an edge labelled annie whose home map has read annie's |
| +// own published edges file, with the given hosts object. The warm set is |
| +// read from publication, not from the route table (#724), so this is how a |
| +// test gives the issuer names of its own. |
| +func publishedEdge(t *testing.T, ownHosts string) (*Edge, *homeMap, release.Store) { |
| + t.Helper() |
| + s := meshTestStore(t) |
| + putJSON(t, s, "control/edges/annie.json", `{"v":1,"box":"annie","eip":"1.1.1.1","hosts":`+ownHosts+`}`) |
| + m := newHomeMap(s, "annie") |
| + refreshHomeMap(t, m) |
| + e := &Edge{} |
| + e.homes.Store(m) |
| + return e, m, s |
| +} |
| + |
| // The warm set is "exact hosts we serve that are not under the apps domain |
| // and not wildcard-covered". Each exclusion below is a separate bug if it |
| // regresses. |
| func TestWarmSetSelectsCustomDomainsOnly(t *testing.T) { |
| - e := &Edge{} |
| - e.upstreams.Store(&map[string]upstream{ |
| - "www.customer.test": {}, |
| - "shop.customer.test": {}, |
| - "app.acct.oncarlos.test": {}, // platform host — apps domain |
| - "c1.app.acct.oncarlos.test": {}, // canary — apps domain, 3 labels |
| - "*.catchall.test": {}, // catch-all — wildcard covers it |
| - "one.go.tito.test": {}, // one label under a configured parent |
| - "deep.one.go.tito.test": {}, // TWO labels under it: NOT covered |
| - }) |
| + e, _, _ := publishedEdge(t, `{ |
| + "www.customer.test": {"role":"home"}, |
| + "shop.customer.test": {"role":"home"}, |
| + "app.acct.oncarlos.test": {"role":"home","platform":true}, |
| + "c1.app.acct.oncarlos.test": {"role":"home"}, |
| + "*.catchall.test": {"role":"home"}, |
| + "one.go.tito.test": {"role":"home"}, |
| + "deep.one.go.tito.test": {"role":"home"}}`) |
| + // platform host and canary: apps domain. Catch-all: a wildcard covers |
| + // it. one.go.tito.test: one label under a configured parent. |
| + // deep.one.go.tito.test: TWO labels under it, NOT covered. |
| parents := func() []string { return []string{"go.tito.test"} } |
| got := e.warmSet("oncarlos.test", parents) |
| @@ -71,8 +88,7 @@ func TestWarmSetSelectsCustomDomainsOnly(t *testing.T) { |
| // exactly the window before their wildcard arrives — the burst the shape |
| // test exists to prevent. |
| func TestWarmSetExcludesChildrenOfAnUnobtainedParent(t *testing.T) { |
| - e := &Edge{} |
| - e.upstreams.Store(&map[string]upstream{"new.acct.test": {}}) |
| + e, _, _ := publishedEdge(t, `{"new.acct.test":{"role":"home"}}`) |
| // currentParents lists the parent; no cert exists for it anywhere. |
| if got := e.warmSet("oncarlos.test", func() []string { return []string{"acct.test"} }); len(got) != 0 { |
| t.Fatalf("warm set = %v; a configured parent covers its children whether or not its cert exists yet", got) |
| @@ -80,13 +96,490 @@ func TestWarmSetExcludesChildrenOfAnUnobtainedParent(t *testing.T) { |
| } |
| func TestWarmSetWithNoWildcardManagerCoversNothing(t *testing.T) { |
| - e := &Edge{} |
| - e.upstreams.Store(&map[string]upstream{"www.customer.test": {}}) |
| + e, _, _ := publishedEdge(t, `{"www.customer.test":{"role":"home"}}`) |
| if got := e.warmSet("oncarlos.test", nil); len(got) != 1 || got[0] != "www.customer.test" { |
| t.Fatalf("warm set = %v, want the custom domain", got) |
| } |
| } |
| +// The warm set is this box's published names and every other box's, and |
| +// nothing from the route table: a name this box serves but has not published |
| +// (an alias attached a moment ago, its DNS record not yet made) is not in |
| +// it. An edge with no home map at all, or no box label, has no publication |
| +// to read and warms nothing. |
| +func TestWarmSetReadsPublicationNotTheRouteTable(t *testing.T) { |
| + e, m, s := publishedEdge(t, `{"published.customer.test":{"role":"home","alias":true,"dns_pointing":true}}`) |
| + putJSON(t, s, "control/edges/betty.json", `{"v":1,"box":"betty","eip":"2.2.2.2","hosts":{"elsewhere.customer.test":{"role":"home","alias":true,"dns_pointing":true}}}`) |
| + refreshHomeMap(t, m) |
| + e.upstreams.Store(&map[string]upstream{ |
| + "published.customer.test": {}, |
| + "fresh.customer.test": {alias: true}, // attached, not yet published |
| + "firstroute.customer.test": {}, // a custom route, likewise |
| + }) |
| + got := e.warmSet("oncarlos.test", nil) |
| + if want := "elsewhere.customer.test,published.customer.test"; strings.Join(got, ",") != want { |
| + t.Fatalf("warm set = %v, want %s: only published names", got, want) |
| + } |
| + |
| + bare := &Edge{} |
| + bare.upstreams.Store(&map[string]upstream{"www.customer.test": {}}) |
| + if got := bare.warmSet("oncarlos.test", nil); len(got) != 0 { |
| + t.Fatalf("an edge with no home map warmed %v from its route table", got) |
| + } |
| + unlabelled := &Edge{} |
| + unlabelled.upstreams.Store(&map[string]upstream{"www.customer.test": {}}) |
| + um := newHomeMap(s, "") |
| + refreshHomeMap(t, um) |
| + unlabelled.homes.Store(um) |
| + if got := unlabelled.warmSet("oncarlos.test", nil); len(got) != 0 { |
| + t.Fatalf("an unlabelled edge warmed %v", got) |
| + } |
| +} |
| + |
| +// issuerWarmFixture is an issuer edge (annie) built through newIssuerWarm, |
| +// the production wiring: the real warmSet, the real dnsGate over a counting |
| +// fake resolver and a fixed edge set, and the real wakes. publish rewrites |
| +// annie's own edges file and has the home map read it. |
| +type issuerWarmFixture struct { |
| + e *Edge |
| + m *homeMap |
| + s release.Store |
| + w *certWarm |
| + mu sync.Mutex |
| + lookups map[string]int |
| + orders map[string]int |
| + // away is the hosts the fake resolver answers with an address outside |
| + // the edge set, so the DNS gate stays shut for them. |
| + away map[string]bool |
| + // refuse is the hosts the fake getCert answers with the given error. |
| + refuse map[string]error |
| + // parents is the wildcard parents the edge has configured; set it |
| + // through setParents. |
| + parents []string |
| +} |
| + |
| +func newIssuerWarmFixture(t *testing.T, ownHosts string) *issuerWarmFixture { |
| + t.Helper() |
| + return newRecordingIssuerWarmFixture(t, ownHosts, nil) |
| +} |
| + |
| +// newRecordingIssuerWarmFixture is newIssuerWarmFixture with a store for |
| +// the warm's failure records (nil records nothing). |
| +func newRecordingIssuerWarmFixture(t *testing.T, ownHosts string, records release.Store) *issuerWarmFixture { |
| + t.Helper() |
| + f := &issuerWarmFixture{lookups: map[string]int{}, orders: map[string]int{}, away: map[string]bool{}, refuse: map[string]error{}} |
| + f.e, f.m, f.s = publishedEdge(t, ownHosts) |
| + f.w = f.e.newIssuerWarm("oncarlos.test", |
| + func() []string { |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + return slices.Clone(f.parents) |
| + }, |
| + func(h *tls.ClientHelloInfo) (*tls.Certificate, error) { |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + f.orders[h.ServerName]++ |
| + if err := f.refuse[h.ServerName]; err != nil { |
| + return nil, err |
| + } |
| + return &tls.Certificate{}, nil |
| + }, |
| + func(host string) ([]string, error) { |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + f.lookups[host]++ |
| + if f.away[host] { |
| + return []string{"192.0.2.1"}, nil |
| + } |
| + return []string{"203.0.113.7"}, nil |
| + }, |
| + func() []string { return []string{"203.0.113.7"} }, |
| + records, |
| + ) |
| + return f |
| +} |
| + |
| +func (f *issuerWarmFixture) publish(t *testing.T, box, hosts string) { |
| + t.Helper() |
| + putJSON(t, f.s, "control/edges/"+box+".json", `{"v":1,"box":"`+box+`","eip":"1.1.1.1","hosts":`+hosts+`}`) |
| + refreshHomeMap(t, f.m) |
| +} |
| + |
| +func (f *issuerWarmFixture) setParents(parents ...string) { |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + f.parents = parents |
| +} |
| + |
| +func (f *issuerWarmFixture) counts(host string) (lookups, orders int) { |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + return f.lookups[host], f.orders[host] |
| +} |
| + |
| +func (f *issuerWarmFixture) totalLookups() int { |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + n := 0 |
| + for _, c := range f.lookups { |
| + n += c |
| + } |
| + return n |
| +} |
| + |
| +// THE assertion for #724. An alias attached on the issuer's own box is in |
| +// its route table at once, before the customer has made the DNS record. The |
| +// warm must not ask the resolver about it then: the box's resolver caches |
| +// "no such name" for the zone's negative TTL, and the certificate then waits |
| +// that long after the record appears. So until the box's own edges file |
| +// publishes the name as pointing: zero lookups, zero orders, however many |
| +// passes and reload wakes go by. After it does: one lookup, one order. |
| +func TestIssuerWarmDoesNotLookUpAnUnpublishedAlias(t *testing.T) { |
| + const alias = "shop.example.com" |
| + f := newIssuerWarmFixture(t, `{"app.acct.oncarlos.test":{"role":"home","platform":true}}`) |
| + f.e.upstreams.Store(&map[string]upstream{ |
| + "app.acct.oncarlos.test": {}, |
| + alias: {alias: true}, |
| + }) |
| + f.w.pass() |
| + f.e.runReloadHooks() // the reload that brought the alias nudges the warm |
| + if f.w.hasNewHost() { |
| + t.Fatal("the warm counts an unpublished alias as a new host: its wake would run a pass that looks the name up") |
| + } |
| + f.w.pass() |
| + if n := f.totalLookups(); n != 0 { |
| + t.Fatalf("%d resolver lookup(s) before the alias was published (%v): the first one plants the negative cache entry", n, f.lookups) |
| + } |
| + |
| + f.publish(t, "annie", `{"app.acct.oncarlos.test":{"role":"home","platform":true},"`+alias+`":{"role":"home","alias":true,"dns_pointing":true}}`) |
| + if !f.w.hasNewHost() { |
| + t.Fatal("the published alias is not a new host to the warm") |
| + } |
| + f.w.pass() |
| + if lookups, orders := f.counts(alias); lookups != 1 || orders != 1 { |
| + t.Fatalf("after publication: %d lookup(s), %d order(s), want 1 and 1", lookups, orders) |
| + } |
| +} |
| + |
| +// A first-route claim is a ROUTE with a custom hostname, published at once |
| +// with dns_pointing false. The warm leaves it alone on the same terms, on |
| +// its own box and on another, until the home box flips the mark. |
| +func TestIssuerWarmWaitsForACustomRouteToPoint(t *testing.T) { |
| + const own, remote = "shop.example.com", "store.example.net" |
| + f := newIssuerWarmFixture(t, `{"`+own+`":{"role":"home","platform":false,"dns_pointing":false}}`) |
| + f.e.upstreams.Store(&map[string]upstream{own: {}}) |
| + f.publish(t, "betty", `{"`+remote+`":{"role":"home","platform":false,"dns_pointing":false}}`) |
| + f.w.pass() |
| + f.w.pass() |
| + if n := f.totalLookups(); n != 0 { |
| + t.Fatalf("%d resolver lookup(s) for routes not yet pointing (%v)", n, f.lookups) |
| + } |
| + |
| + f.publish(t, "annie", `{"`+own+`":{"role":"home","platform":false,"dns_pointing":true}}`) |
| + f.w.pass() |
| + if lookups, orders := f.counts(own); lookups != 1 || orders != 1 { |
| + t.Fatalf("own route after the flip: %d lookup(s), %d order(s), want 1 and 1", lookups, orders) |
| + } |
| + if lookups, _ := f.counts(remote); lookups != 0 { |
| + t.Fatalf("betty's route was looked up %d time(s) before betty saw it pointing", lookups) |
| + } |
| + f.publish(t, "betty", `{"`+remote+`":{"role":"home","platform":false,"dns_pointing":true}}`) |
| + f.w.pass() |
| + if lookups, orders := f.counts(remote); lookups != 1 || orders != 1 { |
| + t.Fatalf("betty's route after the flip: %d lookup(s), %d order(s), want 1 and 1", lookups, orders) |
| + } |
| +} |
| + |
| +// A name published not pointing is not a warm candidate at all, certificate |
| +// or no certificate (#724). One the warm has already warmed, whose home box |
| +// then stamps it not pointing, is left alone: not looked up, not asked of |
| +// autocert, pass after pass. Its cached certificate keeps serving and a |
| +// handshake at the issuer re-arms it; the warm does not. When the name |
| +// points again it is re-armed as the warmed name it is: one getCert, no |
| +// lookup, nothing spent from the order budget. |
| +func TestIssuerWarmLeavesAWarmedNameAloneWhileItIsNotPointing(t *testing.T) { |
| + const own, remote = "shop.example.com", "store.example.net" |
| + pub := func(f *issuerWarmFixture, pointing string) { |
| + f.publish(t, "annie", `{"`+own+`":{"role":"home","platform":false,"dns_pointing":`+pointing+`}}`) |
| + f.publish(t, "betty", `{"`+remote+`":{"role":"home","alias":true,"dns_pointing":`+pointing+`}}`) |
| + } |
| + f := newIssuerWarmFixture(t, `{}`) |
| + pub(f, "true") |
| + f.w.pass() |
| + for _, h := range []string{own, remote} { |
| + if lookups, asks := f.counts(h); lookups != 1 || asks != 1 { |
| + t.Fatalf("%s, first order: %d lookup(s), %d getCert call(s), want 1 and 1", h, lookups, asks) |
| + } |
| + } |
| + spent := len(f.w.recentOrders) |
| + |
| + pub(f, "false") |
| + if f.w.hasNewHost() { |
| + t.Fatal("a warmed name that stopped pointing counts as a new host") |
| + } |
| + f.w.pass() |
| + f.w.pass() |
| + for _, h := range []string{own, remote} { |
| + if lookups, asks := f.counts(h); lookups != 1 || asks != 1 { |
| + t.Fatalf("%s while not pointing: %d lookup(s), %d getCert call(s); want still 1 and 1, the warm leaves it alone", h, lookups, asks) |
| + } |
| + if !f.w.warmed[h] { |
| + t.Fatalf("%s was forgotten as warmed while it was not pointing: pointing again would cost a new gated order", h) |
| + } |
| + } |
| + |
| + pub(f, "true") |
| + if f.w.hasNewHost() { |
| + t.Fatal("a warmed name that points again counts as a new host") |
| + } |
| + f.w.pass() |
| + for _, h := range []string{own, remote} { |
| + if lookups, asks := f.counts(h); lookups != 1 || asks != 2 { |
| + t.Fatalf("%s pointing again: %d lookup(s), %d getCert call(s); want 1 and 2 (re-armed once, ungated)", h, lookups, asks) |
| + } |
| + } |
| + if n := len(f.w.recentOrders); n != spent { |
| + t.Fatalf("the re-arms spent order budget: %d stamp(s), was %d", n, spent) |
| + } |
| +} |
| + |
| +// A failure record belongs to the attachment, not to the name's turn in the |
| +// warm set. A rate-limited name whose home box then publishes it not |
| +// pointing has left the set, but its twelve-hour backoff stays in force: |
| +// the record that explains the wait, and its attempt count, must stay too. |
| +// The same holds when a wildcard parent starts covering the name while it |
| +// is still published. Only a name no box publishes any more is pruned as |
| +// detached. |
| +func TestIssuerWarmKeepsAFailureRecordWhileTheNameIsStillDeployed(t *testing.T) { |
| + const name, gone, other = "shop.example.com", "old.example.org", "store.example.net" |
| + row := func(h, pointing string) string { |
| + return `"` + h + `":{"role":"home","platform":false,"dns_pointing":` + pointing + `}` |
| + } |
| + records := release.NewDirStore(t.TempDir()) |
| + f := newRecordingIssuerWarmFixture(t, `{`+row(name, "true")+`,`+row(gone, "true")+`,`+row(other, "true")+`}`, records) |
| + limited := &acme.Error{ProblemType: "urn:ietf:params:acme:error:rateLimited"} |
| + f.refuse[name], f.refuse[gone] = limited, limited |
| + f.w.pass() |
| + for _, h := range []string{name, gone} { |
| + if rec, ok := warmRecordIn(t, records, h); !ok || rec.Class != certwarm.ClassRateLimited || rec.Attempts != 1 { |
| + t.Fatalf("setup: record for %s = %+v ok=%v, want one rate-limited attempt", h, rec, ok) |
| + } |
| + } |
| + before, _ := warmRecordIn(t, records, name) |
| + until := f.w.nextAttempt[name] |
| + if left := time.Until(until); left < warmRateLimitBackoff-time.Minute { |
| + t.Fatalf("setup: backoff of %s, want about %s", left, warmRateLimitBackoff) |
| + } |
| + |
| + // The name stops pointing and the other failing name is detached |
| + // outright, while a third name keeps the set from being empty. |
| + f.publish(t, "annie", `{`+row(name, "false")+`,`+row(other, "true")+`}`) |
| + f.w.pass() |
| + if rec, ok := warmRecordIn(t, records, name); !ok || rec != before { |
| + t.Fatalf("not pointing but still published: record = %+v ok=%v, want %+v kept", rec, ok, before) |
| + } |
| + if got := f.w.nextAttempt[name]; !got.Equal(until) { |
| + t.Fatalf("the backoff moved from %s to %s while the name was not pointing", until, got) |
| + } |
| + if rec, ok := warmRecordIn(t, records, gone); ok { |
| + t.Fatalf("record %+v for a name no box publishes survived the prune", rec) |
| + } |
| + |
| + f.publish(t, "annie", `{`+row(name, "true")+`,`+row(other, "true")+`}`) |
| + f.w.pass() |
| + if lookups, asks := f.counts(name); lookups != 1 || asks != 1 { |
| + t.Fatalf("pointing again inside the backoff: %d lookup(s), %d getCert call(s); want still 1 and 1", lookups, asks) |
| + } |
| + if rec, ok := warmRecordIn(t, records, name); !ok || rec != before { |
| + t.Fatalf("pointing again: record = %+v ok=%v, want %+v intact", rec, ok, before) |
| + } |
| + |
| + // A wildcard parent starts covering the name while its home box still |
| + // publishes it. It is no longer a warm candidate, but it is still |
| + // attached: the record and the backoff stay. |
| + f.setParents("example.com") |
| + if slices.Contains(f.w.hosts(), name) { |
| + t.Fatal("setup: the wildcard-covered name is still a warm candidate") |
| + } |
| + f.w.pass() |
| + if rec, ok := warmRecordIn(t, records, name); !ok || rec != before { |
| + t.Fatalf("wildcard-covered but still published: record = %+v ok=%v, want %+v kept", rec, ok, before) |
| + } |
| + if got := f.w.nextAttempt[name]; !got.Equal(until) { |
| + t.Fatalf("the backoff moved from %s to %s while a wildcard covered the name", until, got) |
| + } |
| + |
| + // The cover goes away inside the backoff: the name waits it out, with |
| + // the record still there to say why. |
| + f.setParents() |
| + f.w.pass() |
| + if lookups, asks := f.counts(name); lookups != 1 || asks != 1 { |
| + t.Fatalf("uncovered again inside the backoff: %d lookup(s), %d getCert call(s); want still 1 and 1", lookups, asks) |
| + } |
| + if rec, ok := warmRecordIn(t, records, name); !ok || rec != before { |
| + t.Fatalf("uncovered again: record = %+v ok=%v, want %+v intact", rec, ok, before) |
| + } |
| + |
| + // The control: once no box publishes the name, its record is pruned. |
| + f.publish(t, "annie", `{`+row(other, "true")+`}`) |
| + f.w.pass() |
| + if rec, ok := warmRecordIn(t, records, name); ok { |
| + t.Fatalf("record %+v for a name no box publishes survived the prune", rec) |
| + } |
| +} |
| + |
| +// The wake agrees with the pass: a name is a new host only once its home |
| +// box publishes it pointing, and stops being one when that is withdrawn. |
| +func TestIssuerWarmNewHostFollowsPointing(t *testing.T) { |
| + const name = "shop.example.com" |
| + f := newIssuerWarmFixture(t, `{"`+name+`":{"role":"home","platform":false,"dns_pointing":false}}`) |
| + if f.w.hasNewHost() { |
| + t.Fatal("a not-pointing name counts as a new host") |
| + } |
| + f.publish(t, "annie", `{"`+name+`":{"role":"home","platform":false,"dns_pointing":true}}`) |
| + if !f.w.hasNewHost() { |
| + t.Fatal("the name is not a new host once its home box sees it pointing") |
| + } |
| + f.publish(t, "annie", `{"`+name+`":{"role":"home","platform":false,"dns_pointing":false}}`) |
| + if f.w.hasNewHost() { |
| + t.Fatal("the name is still a new host after its home box withdrew the mark") |
| + } |
| + if n := f.totalLookups(); n != 0 { |
| + t.Fatalf("hasNewHost looked %d name(s) up", n) |
| + } |
| +} |
| + |
| +// A pointing name the issuer's own gate refuses goes on the DNS-miss |
| +// schedule, whose probes look it up. When its home box then publishes it |
| +// not pointing it has left the set, and the schedule must let go of it |
| +// before the next lookup: at the probe (the next full pass can be an hour |
| +// away) and at the full pass. |
| +func TestIssuerWarmRetiresADNSMissWhenTheNameStopsPointing(t *testing.T) { |
| + const name, other = "shop.example.com", "store.example.net" |
| + hosts := func(pointing string) string { |
| + return `{"` + name + `":{"role":"home","platform":false,"dns_pointing":` + pointing + `},"` + other + `":{"role":"home","platform":false,"dns_pointing":true}}` |
| + } |
| + missed := func(t *testing.T) *issuerWarmFixture { |
| + t.Helper() |
| + f := newIssuerWarmFixture(t, hosts("true")) |
| + f.away[name] = true |
| + f.w.pass() |
| + if _, ok := f.w.dnsMisses[name]; !ok { |
| + t.Fatal("setup: the name the gate refused is not on the DNS-miss schedule") |
| + } |
| + if lookups, asks := f.counts(name); lookups != 1 || asks != 0 { |
| + t.Fatalf("setup: %d lookup(s), %d order(s), want 1 and 0", lookups, asks) |
| + } |
| + f.publish(t, "annie", hosts("false")) |
| + return f |
| + } |
| + |
| + t.Run("probe", func(t *testing.T) { |
| + f := missed(t) |
| + // Well past the entry's next check: the probe would look it up. |
| + f.w.now = func() time.Time { return time.Now().Add(warmDNSRetrySlow + time.Minute) } |
| + if f.w.probeDNS() { |
| + t.Fatal("the probe reported a name that points here") |
| + } |
| + if lookups, _ := f.counts(name); lookups != 1 { |
| + t.Fatalf("the probe looked a not-pointing name up: %d lookup(s), want still 1", lookups) |
| + } |
| + if _, ok := f.w.dnsMisses[name]; ok { |
| + t.Fatal("the name is still on the DNS-miss schedule after it left the set") |
| + } |
| + if _, wait := f.w.dnsWait(); wait { |
| + t.Fatal("a DNS re-check is still scheduled") |
| + } |
| + }) |
| + t.Run("pass", func(t *testing.T) { |
| + f := missed(t) |
| + f.w.pass() |
| + if _, ok := f.w.dnsMisses[name]; ok { |
| + t.Fatal("the name is still on the DNS-miss schedule after a full pass without it") |
| + } |
| + if lookups, _ := f.counts(name); lookups != 1 { |
| + t.Fatalf("the pass looked a not-pointing name up: %d lookup(s), want still 1", lookups) |
| + } |
| + }) |
| +} |
| + |
| +// A name re-armed as already warmed has no first order left to wait for DNS |
| +// on, so a DNS-miss entry for it is retired on that path. It stays in the |
| +// set, so the prune would keep it and its probes would go on. |
| +func TestIssuerWarmRetiresADNSMissOnTheReArmPath(t *testing.T) { |
| + const name = "shop.example.com" |
| + f := newIssuerWarmFixture(t, `{"`+name+`":{"role":"home","platform":false,"dns_pointing":true}}`) |
| + f.w.pass() |
| + if !f.w.warmed[name] { |
| + t.Fatal("setup: the name was not warmed") |
| + } |
| + f.w.dnsMissed(name, f.w.now()) |
| + f.w.pass() |
| + if _, ok := f.w.dnsMisses[name]; ok { |
| + t.Fatal("a re-armed name is still on the DNS-miss schedule") |
| + } |
| + if lookups, asks := f.counts(name); lookups != 1 || asks != 2 { |
| + t.Fatalf("%d lookup(s), %d getCert call(s), want 1 and 2", lookups, asks) |
| + } |
| +} |
| + |
| +// Authority before work. A box that is not the issuer reads no set, looks |
| +// nothing up and asks autocert for nothing: not in a pass, not on a wake, |
| +// not at a DNS re-check that is due. |
| +func TestIssuerWarmDoesNoCandidateWorkWithoutTheLease(t *testing.T) { |
| + const name, missing = "shop.example.com", "store.example.net" |
| + f := newIssuerWarmFixture(t, `{ |
| + "`+name+`":{"role":"home","platform":false,"dns_pointing":true}, |
| + "`+missing+`":{"role":"home","platform":false,"dns_pointing":true}}`) |
| + f.away[missing] = true |
| + f.w.pass() |
| + if _, ok := f.w.dnsMisses[missing]; !ok { |
| + t.Fatal("setup: no DNS-miss entry to probe") |
| + } |
| + lookups, setReads := f.totalLookups(), 0 |
| + _, asks := f.counts(name) |
| + set := f.w.hosts |
| + f.w.hosts = func() []string { setReads++; return set() } |
| + f.w.issuer = func() (context.Context, bool) { return context.Background(), false } |
| + f.w.now = func() time.Time { return time.Now().Add(warmDNSRetrySlow + time.Minute) } |
| + |
| + if d := f.w.pass(); d != warmInterval { |
| + t.Fatalf("a non-issuer's pass asked to come back in %s, want %s", d, warmInterval) |
| + } |
| + if f.w.hasNewHost() { |
| + t.Fatal("a non-issuer reported a new host") |
| + } |
| + if f.w.probeDNS() { |
| + t.Fatal("a non-issuer's probe reported a name that points here") |
| + } |
| + if setReads != 0 { |
| + t.Fatalf("a non-issuer read the warm set %d time(s)", setReads) |
| + } |
| + if n := f.totalLookups(); n != lookups { |
| + t.Fatalf("a non-issuer made %d resolver lookup(s)", n-lookups) |
| + } |
| + if _, n := f.counts(name); n != asks { |
| + t.Fatalf("a non-issuer made %d getCert call(s)", n-asks) |
| + } |
| + if _, ok := f.w.dnsMisses[missing]; !ok { |
| + t.Fatal("a non-issuer changed the DNS-miss schedule") |
| + } |
| +} |
| + |
| +// Publication wakes the warm. newIssuerWarm hands the home map its nudge, so |
| +// the refresh that reads the flipped mark starts a pass by itself, and the |
| +// certificate does not wait for the hourly one. |
| +func TestIssuerWarmIsWokenByItsOwnPublication(t *testing.T) { |
| + const alias = "shop.example.com" |
| + f := newIssuerWarmFixture(t, `{}`) |
| + passes := loopWarm(t, f.w) |
| + f.publish(t, "annie", `{"`+alias+`":{"role":"home","alias":true,"dns_pointing":true}}`) |
| + waitCount(t, passes, 2, "passes") |
| + if lookups, orders := f.counts(alias); lookups != 1 || orders != 1 { |
| + t.Fatalf("after the wake: %d lookup(s), %d order(s), want 1 and 1", lookups, orders) |
| + } |
| +} |
| + |
| // ALL answers must be in the edge set. A name mid-migration resolves to the |
| // old host AND ours; an any-match gate passes it, the order goes out, and |
| // validation fails from the CA's vantage anyway — burning the shared |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index 0d012d33c..ab9c51822 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -4900,19 +4900,9 @@ func RunWithActivatorReady(args []string, act Activator, cache *Cache, ready fun |
| defer cancel() |
| return edgesfile.EdgeIPs(ctx, store, envIPs, time.Now()) |
| } |
| - warm := newCertWarm( |
| - func() []string { return e.warmSet(appsDomain, parents) }, |
| - perHostCert, |
| - dnsGate(warmResolver, edgeIPs), |
| - e.issuerGate, |
| - store, |
| - ) |
| - // Woken when its set may have grown (#386), so a custom domain is |
| - // ordered seconds after it reaches this box rather than at the next |
| - // hourly pass: a local route reload, or a change in the names other |
| - // boxes home. A wake with nothing new in the set is dropped. |
| - e.OnReload(warm.nudge) |
| - e.homes.Load().setServedWake(warm.nudge) |
| + // The set, the DNS gate and the wakes are newIssuerWarm's |
| + // (certwarm.go). |
| + warm := e.newIssuerWarm(appsDomain, parents, perHostCert, warmResolver, edgeIPs, store) |
| go warm.run() |
| log.Printf("edge: cert warm on (%s pass) — custom domains are ordered and renewed proactively, not on first handshake", warmInterval) |
| } |
diff --git a/internal/edge/homemap.go b/internal/edge/homemap.go| index 8579f5828..247777093 100644 |
| --- a/internal/edge/homemap.go |
| +++ b/internal/edge/homemap.go |
| @@ -238,6 +238,10 @@ type edgesHostView struct { |
| // by edgesfile/testdata/assets-host.golden.json. Absent on a file from an |
| // unarmed box or a publisher that predates it, which reads as no block. |
| Assets *edgesAssetsView `json:"assets,omitempty"` |
| + // DNSPointing is the publisher's own DNS verdict for a custom name |
| + // (#724). Absent reads as pointing: edgesfile.DNSPointing is its only |
| + // reader, and holds the compatibility rule. |
| + DNSPointing *bool `json:"dns_pointing,omitempty"` |
| } |
| // edgesAssetsView is the wire shape of the assets block: path prefixes, the |
| @@ -266,6 +270,10 @@ type homeEntry struct { |
| // dial reports whether the entry is a backhaul target (role home). A |
| // cert-only wildcard entry folds with dial false and Home skips it. |
| dial bool |
| + // pointing reports whether any box homing the name has seen its DNS |
| + // point at this deployment (edgesfile.DNSPointing, unioned across home |
| + // rows like the classes). ServedHosts lists only such names (#724). |
| + pointing bool |
| // account and app are the owner the dial target's box published. They |
| // travel with eip and box and are never merged across entries. |
| account, app string |
| @@ -296,6 +304,14 @@ type homeSnapshot struct { |
| files map[string]edgesFileView |
| // hosts is the fold: host → home, own box already excluded. |
| hosts map[string]homeEntry |
| + // ownServed is OwnServedHosts' answer: this box's own published exact |
| + // home names whose DNS it has seen pointing. Sorted, never written after |
| + // the snapshot is published. |
| + ownServed []string |
| + // deployed is DeployedHosts' answer: every exact home name any box's |
| + // file publishes, this box's included, whatever its DNS mark. Sorted, |
| + // never written after the snapshot is published. |
| + deployed []string |
| // read is set once the snapshot comes from a successful hosts refresh: |
| // the empty snapshot a restart starts from is not an answer (AssetsFor). |
| read bool |
| @@ -321,11 +337,12 @@ type homeMap struct { |
| snap *homeSnapshot |
| // hostsWake fires after a Refresh that changed the NAME set (setHostsWake). |
| hostsWake func() |
| - // servedWake fires after a Refresh that changed the ServedHosts set |
| - // (setServedWake): the cert warm's cue that a custom domain was attached |
| - // on another box (#386). Separate from hostsWake because their filters |
| - // are opposites: hostsWake ignores exactly the unclassed rows a custom |
| - // domain arrives as. |
| + // servedWake fires after a Refresh that changed the ServedHosts set or |
| + // the OwnServedHosts set (setServedWake): the cert warm's cue that a |
| + // custom domain was attached on another box (#386), or that this box or |
| + // another published one as pointing (#724). Separate from hostsWake |
| + // because their filters are opposites: hostsWake ignores exactly the |
| + // unclassed rows a custom domain arrives as. |
| servedWake func() |
| // partialPolls counts polls that could not read (or parse) every object, |
| // for the first-and-every-tenth log cadence. |
| @@ -639,7 +656,7 @@ func (m *homeMap) refreshHosts(ctx context.Context) error { |
| // deterministic; say so once a refresh. |
| log.Printf("edge: home map: %d host(s) published by two boxes at the same installation stamp, e.g. %s", len(tied), tied[0]) |
| } |
| - snap := &homeSnapshot{groupObserved: m.snapshot().groupObserved, files: next, hosts: hosts, read: true, departureComplete: failed == 0, readerComplete: failed == 0 && !readerMissing} |
| + snap := &homeSnapshot{groupObserved: m.snapshot().groupObserved, files: next, hosts: hosts, ownServed: ownServedHosts(next, m.self), deployed: deployedHosts(next, m.self), read: true, departureComplete: failed == 0, readerComplete: failed == 0 && !readerMissing} |
| m.mu.Lock() |
| m.snap = snap |
| wake := m.hostsWake |
| @@ -658,7 +675,10 @@ func (m *homeMap) refreshHosts(ctx context.Context) error { |
| // that. |
| go wake() |
| } |
| - if served != nil && !sameServedSet(prev.hosts, snap.hosts) { |
| + if served != nil && (!sameServedSet(prev.hosts, snap.hosts) || !slices.Equal(prev.ownServed, snap.ownServed)) { |
| + // Either half of the warm set moved: another box's names, or this |
| + // box's own publication (a custom name it has just stamped |
| + // "pointing", #724). |
| go served() |
| } |
| return nil |
| @@ -666,7 +686,8 @@ func (m *homeMap) refreshHosts(ctx context.Context) error { |
| // sameServedSet reports whether two folds serve the same exact names, by |
| // ServedHosts' filter. Addresses and owners moving change nothing here: the |
| -// warm's question is only which names exist. |
| +// warm's question is only which names exist. A name whose publisher flips |
| +// it to pointing joins the set, so the flip is a change (#724). |
| func sameServedSet(a, b map[string]homeEntry) bool { |
| n := 0 |
| for h, e := range a { |
| @@ -686,9 +707,37 @@ func sameServedSet(a, b map[string]homeEntry) bool { |
| return n == 0 |
| } |
| -// servedInput is ServedHosts' filter: a dialable, exact name. |
| +// servedInput is ServedHosts' filter: a dialable, exact name that a box |
| +// homing it has seen pointing here (every name but a custom one a current |
| +// publisher has not stamped yet: edgesfile.DNSPointing). |
| func servedInput(host string, e homeEntry) bool { |
| - return e.dial && !strings.HasPrefix(host, "*.") |
| + return e.dial && e.pointing && !strings.HasPrefix(host, "*.") |
| +} |
| + |
| +// ownServedHosts is OwnServedHosts' answer for one poll's files: the exact |
| +// names this box's own file publishes as home, DNS pointing. The own file is |
| +// the one foldHomes leaves out of the fold (Box == self), so between them the |
| +// two sets read every file exactly once. That is about files, not names: a |
| +// name homed here and on another box is in both sets, and the warm set |
| +// removes the duplicate. Sorted; nil for an unlabelled box. |
| +func ownServedHosts(files map[string]edgesFileView, self string) []string { |
| + if self == "" { |
| + return nil |
| + } |
| + var out []string |
| + for _, f := range files { |
| + if f.Box != self { |
| + continue |
| + } |
| + for host, h := range f.Hosts { |
| + if host == "" || strings.HasPrefix(host, "*.") || h.Role != edgeRoleHome || !edgesfile.DNSPointing(h.DNSPointing) { |
| + continue |
| + } |
| + out = append(out, host) |
| + } |
| + } |
| + slices.Sort(out) |
| + return slices.Compact(out) |
| } |
| // samePlatformSet reports whether two folds name the same PLATFORM hosts — |
| @@ -799,6 +848,11 @@ func (m *homeMap) Hosts() []string { |
| // autocert refuses the wildcard label anyway (Allowed). Only dial-able |
| // entries count — a cert-only wildcard row homes nothing. |
| // |
| +// A custom name its publisher has not seen pointing yet is left out (#724, |
| +// edgesfile.DNSPointing): the cert warm looks up every name listed here |
| +// through this box's caching resolver, and a lookup made before the record |
| +// exists is remembered as "no such name" for the zone's negative TTL. |
| +// |
| // An unlabelled box (self == "") reports nothing, as Home does: an edge that |
| // cannot tell its own rows from another box's must not answer at all. |
| func (m *homeMap) ServedHosts() []string { |
| @@ -817,6 +871,68 @@ func (m *homeMap) ServedHosts() []string { |
| return out |
| } |
| +// OwnServedHosts is ServedHosts' other half: the exact names THIS box homes, |
| +// read from its own published edges file as the home map last polled it and |
| +// not from its route table. The fold leaves the own file out, so |
| +// ServedHosts does not read it; a name another box homes too is in both. |
| +// |
| +// The published file is the source on purpose (#724). The route table gains |
| +// a custom domain the moment it is attached, before its DNS record need |
| +// exist; the file gains an alias only once this box's DNS sweep has stamped |
| +// it "pointing", and marks a custom route dns_pointing false until the same |
| +// stamp. So a name listed here is one whose record this box has already |
| +// seen, and the cert warm's first cached lookup of it cannot be the one that |
| +// plants "no such name". |
| +// |
| +// Sorted, nil-safe, and nothing for an unlabelled box, as ServedHosts. |
| +func (m *homeMap) OwnServedHosts() []string { |
| + if m == nil || m.self == "" { |
| + return nil |
| + } |
| + return slices.Clone(m.snapshot().ownServed) |
| +} |
| + |
| +// deployedHosts is DeployedHosts' answer for one poll's files: the exact |
| +// names any box's file publishes as home, this box's own included, with no |
| +// regard for the DNS mark. Sorted; nil for an unlabelled box. |
| +func deployedHosts(files map[string]edgesFileView, self string) []string { |
| + if self == "" { |
| + return nil |
| + } |
| + seen := map[string]bool{} |
| + var out []string |
| + for _, f := range files { |
| + for host, h := range f.Hosts { |
| + if host == "" || seen[host] || strings.HasPrefix(host, "*.") || h.Role != edgeRoleHome { |
| + continue |
| + } |
| + seen[host] = true |
| + out = append(out, host) |
| + } |
| + } |
| + slices.Sort(out) |
| + return out |
| +} |
| + |
| +// DeployedHosts lists every exact name some box in this deployment still |
| +// publishes as home, this box included, pointing or not. It answers a |
| +// different question from ServedHosts and OwnServedHosts: not "may the cert |
| +// warm order this name?" but "is this name still attached anywhere?". The |
| +// cert warm keeps a name's failure record for as long as the name is listed |
| +// here, so a name whose DNS is withdrawn for a while does not lose the |
| +// record that explains its retry backoff (#724). It is never a source of |
| +// warm candidates: nothing listed here is looked up or ordered for being |
| +// listed. |
| +// |
| +// The same snapshot as the two served sets, so no extra read. Sorted, |
| +// nil-safe, and nothing for an unlabelled box. |
| +func (m *homeMap) DeployedHosts() []string { |
| + if m == nil || m.self == "" { |
| + return nil |
| + } |
| + return slices.Clone(m.snapshot().deployed) |
| +} |
| + |
| // setHostsWake installs the callback a changed host set fires (Refresh). |
| // Under the map's own lock: run() is already polling when the wildcard |
| // manager is wired in after it. |
| @@ -829,8 +945,8 @@ func (m *homeMap) setHostsWake(fn func()) { |
| m.mu.Unlock() |
| } |
| -// setServedWake installs the callback a changed ServedHosts set fires |
| -// (Refresh), on the same terms as setHostsWake. |
| +// setServedWake installs the callback a changed ServedHosts or |
| +// OwnServedHosts set fires (Refresh), on the same terms as setHostsWake. |
| func (m *homeMap) setServedWake(fn func()) { |
| if m == nil { |
| return |
| @@ -935,6 +1051,7 @@ func foldHomes(files map[string]edgesFileView, self string, privateDial bool) (m |
| merged := hosts[host] |
| merged.platform = merged.platform || (h.Platform && !h.Alias && !h.Wildcard) |
| merged.wildcard = merged.wildcard || h.Wildcard |
| + merged.pointing = merged.pointing || (h.Role == edgeRoleHome && edgesfile.DNSPointing(h.DNSPointing)) |
| hosts[host] = merged |
| } |
| } |
| @@ -951,7 +1068,7 @@ func foldHomes(files map[string]edgesFileView, self string, privateDial bool) (m |
| } |
| h.claims = cs |
| h.routeExists = r.RouteExists |
| - h.platform, h.wildcard = classes.platform, classes.wildcard |
| + h.platform, h.wildcard, h.pointing = classes.platform, classes.wildcard, classes.pointing |
| hosts[name] = h |
| } |
diff --git a/internal/edge/homemap_dnspointing_test.go b/internal/edge/homemap_dnspointing_test.go| new file mode 100644 |
| index 000000000..b5731b0c4 |
| --- /dev/null |
| +++ b/internal/edge/homemap_dnspointing_test.go |
| @@ -0,0 +1,118 @@ |
| +package edge |
| + |
| +import ( |
| + "strings" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| +) |
| + |
| +// #724: the home map's two name sets for the cert warm, this box's own |
| +// publication (OwnServedHosts) and every other box's (ServedHosts), leave |
| +// out a custom name whose home box has not seen it pointing, and gain it |
| +// when that box flips the mark. Either flip wakes the warm. |
| +func TestHomeMapServedSetsWaitForDNSPointing(t *testing.T) { |
| + s := meshTestStore(t) |
| + own := func(pointing string) { |
| + putJSON(t, s, "control/edges/annie.json", `{"v":1,"box":"annie","eip":"1.1.1.1","hosts":{ |
| + "app.acct.apps.test":{"role":"home","platform":true}, |
| + "*.catch.example.com":{"role":"home"}, |
| + "cert.example.com":{"role":"wildcard"}, |
| + "shop.example.com":{"role":"home","platform":false,"dns_pointing":`+pointing+`}}}`) |
| + } |
| + other := func(pointing string) { |
| + putJSON(t, s, "control/edges/betty.json", `{"v":1,"box":"betty","eip":"2.2.2.2","hosts":{ |
| + "old.example.net":{"role":"home","alias":true}, |
| + "store.example.net":{"role":"home","platform":false,"dns_pointing":`+pointing+`}}}`) |
| + } |
| + own("false") |
| + other("false") |
| + m := newHomeMap(s, "annie") |
| + var woke atomic.Int32 |
| + m.setServedWake(func() { woke.Add(1) }) |
| + refreshHomeMap(t, m) |
| + waitWoke(t, &woke, 1) |
| + |
| + sets := func() (string, string) { |
| + return strings.Join(m.OwnServedHosts(), ","), strings.Join(m.ServedHosts(), ",") |
| + } |
| + // The apps-domain row carries no mark and is listed (the warm drops it by |
| + // domain); the wildcard row and the cert-only row are not exact homes. |
| + // old.example.net carries no mark: a publisher from before it existed. |
| + if o, r := sets(); o != "app.acct.apps.test" || r != "old.example.net" { |
| + t.Fatalf("before any flip: own %q, others %q; want app.acct.apps.test and old.example.net", o, r) |
| + } |
| + |
| + // This box stamps its own route pointing. |
| + own("true") |
| + refreshHomeMap(t, m) |
| + waitWoke(t, &woke, 2) |
| + if o, r := sets(); o != "app.acct.apps.test,shop.example.com" || r != "old.example.net" { |
| + t.Fatalf("after the own flip: own %q, others %q", o, r) |
| + } |
| + |
| + // Betty stamps hers. |
| + other("true") |
| + refreshHomeMap(t, m) |
| + waitWoke(t, &woke, 3) |
| + if o, r := sets(); o != "app.acct.apps.test,shop.example.com" || r != "old.example.net,store.example.net" { |
| + t.Fatalf("after betty's flip: own %q, others %q", o, r) |
| + } |
| + |
| + // Nothing moved: no wake. |
| + refreshHomeMap(t, m) |
| + time.Sleep(20 * time.Millisecond) |
| + if woke.Load() != 3 { |
| + t.Fatalf("an unchanged refresh woke the warm (%d)", woke.Load()) |
| + } |
| + |
| + // A record that goes away takes the name back out, on either side. |
| + own("false") |
| + other("false") |
| + refreshHomeMap(t, m) |
| + waitWoke(t, &woke, 4) |
| + if o, r := sets(); o != "app.acct.apps.test" || r != "old.example.net" { |
| + t.Fatalf("after both marks cleared: own %q, others %q", o, r) |
| + } |
| + |
| + // The caller may keep and change what it was handed. |
| + got := m.OwnServedHosts() |
| + got[0] = "scribbled" |
| + if o, _ := sets(); o != "app.acct.apps.test" { |
| + t.Fatalf("OwnServedHosts handed out the snapshot's own slice: %q", o) |
| + } |
| +} |
| + |
| +// An unlabelled box cannot tell its own file from another box's, so it |
| +// reports no names of either kind, as ServedHosts always has. A nil map |
| +// (no deployment store) likewise. |
| +func TestHomeMapOwnServedHostsNeedsABoxLabel(t *testing.T) { |
| + s := meshTestStore(t) |
| + putJSON(t, s, "control/edges/annie.json", `{"v":1,"box":"annie","eip":"1.1.1.1","hosts":{"shop.example.com":{"role":"home","dns_pointing":true}}}`) |
| + m := newHomeMap(s, "") |
| + refreshHomeMap(t, m) |
| + if got := m.OwnServedHosts(); len(got) != 0 { |
| + t.Fatalf("an unlabelled box reported own hosts %v", got) |
| + } |
| + if got := m.ServedHosts(); len(got) != 0 { |
| + t.Fatalf("an unlabelled box reported served hosts %v", got) |
| + } |
| + var nilMap *homeMap |
| + if got := nilMap.OwnServedHosts(); got != nil { |
| + t.Fatalf("a nil map reported %v", got) |
| + } |
| +} |
| + |
| +// Two boxes homing one name (a static site runs on every box): it is listed |
| +// as soon as either has seen it pointing. |
| +func TestHomeMapServedHostsPointingOnAnyHomeBox(t *testing.T) { |
| + s := meshTestStore(t) |
| + putJSON(t, s, "control/edges/annie.json", `{"v":1,"box":"annie","eip":"1.1.1.1","hosts":{}}`) |
| + putJSON(t, s, "control/edges/betty.json", `{"v":1,"box":"betty","eip":"2.2.2.2","hosts":{"shop.example.com":{"role":"home","dns_pointing":false}}}`) |
| + putJSON(t, s, "control/edges/carol.json", `{"v":1,"box":"carol","eip":"3.3.3.3","hosts":{"shop.example.com":{"role":"home","dns_pointing":true}}}`) |
| + m := newHomeMap(s, "annie") |
| + refreshHomeMap(t, m) |
| + if got := m.ServedHosts(); len(got) != 1 || got[0] != "shop.example.com" { |
| + t.Fatalf("served hosts = %v, want shop.example.com", got) |
| + } |
| +} |
diff --git a/internal/edgesfile/dnspointing_test.go b/internal/edgesfile/dnspointing_test.go| new file mode 100644 |
| index 000000000..bec20d1e1 |
| --- /dev/null |
| +++ b/internal/edgesfile/dnspointing_test.go |
| @@ -0,0 +1,33 @@ |
| +package edgesfile |
| + |
| +import "testing" |
| + |
| +// The compatibility rule (#724): a host entry with no dns_pointing mark reads |
| +// as pointing, whichever kind it is. A box that predates the mark publishes |
| +// an alias only once it is pointing and a route whatever its DNS, and both |
| +// must stay in the issuer's warm set through a mixed-version roll. Only an |
| +// explicit false withholds a name. |
| +func TestDNSPointingAbsentReadsAsPointing(t *testing.T) { |
| + f, err := Parse([]byte(`{"v":1,"box":"annie","eip":"1.1.1.1","hosts":{ |
| + "old-alias.example.com":{"role":"home","platform":false,"alias":true}, |
| + "old-route.example.com":{"role":"home","platform":false}, |
| + "waiting.example.com":{"role":"home","platform":false,"dns_pointing":false}, |
| + "pointing.example.com":{"role":"home","platform":false,"dns_pointing":true}}}`)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for host, want := range map[string]bool{ |
| + "old-alias.example.com": true, |
| + "old-route.example.com": true, |
| + "waiting.example.com": false, |
| + "pointing.example.com": true, |
| + } { |
| + if got := f.Hosts[host].Pointing(); got != want { |
| + t.Errorf("%s: Pointing() = %v, want %v", host, got, want) |
| + } |
| + } |
| + yes, no := true, false |
| + if !DNSPointing(nil) || !DNSPointing(&yes) || DNSPointing(&no) { |
| + t.Error("DNSPointing: want nil and true to read as pointing, false as not") |
| + } |
| +} |
diff --git a/internal/edgesfile/edgesfile.go b/internal/edgesfile/edgesfile.go| index 35a34f49a..a863a5da4 100644 |
| --- a/internal/edgesfile/edgesfile.go |
| +++ b/internal/edgesfile/edgesfile.go |
| @@ -69,8 +69,31 @@ type Host struct { |
| // testdata/assets-host.golden.json. Additive: nil on a file without it, |
| // which includes every file an unarmed box writes. |
| Assets *HostAssets `json:"assets,omitempty"` |
| + // DNSPointing is the home box's own DNS verdict for a custom name (one |
| + // outside the apps domain): true once its DNS sweep has stamped the name |
| + // "pointing", false until then. A pointer because absent is not false: |
| + // read it through Pointing, never directly (#724). |
| + DNSPointing *bool `json:"dns_pointing,omitempty"` |
| } |
| +// Pointing reports whether the publishing box has seen the name's DNS point |
| +// at this deployment. See DNSPointing. |
| +func (h Host) Pointing() bool { return DNSPointing(h.DNSPointing) } |
| + |
| +// DNSPointing reads a host entry's dns_pointing mark, and is the one place |
| +// the compatibility rule lives: an ABSENT mark reads as pointing. |
| +// |
| +// A publisher that predates the mark publishes an alias only once it is |
| +// pointing, and publishes a route whatever its DNS, which the issuer's cert |
| +// warm then looked up for itself. Reading absent as true keeps both exactly |
| +// as they were through a mixed-version roll. A current publisher also leaves |
| +// the mark off every name that has no DNS verdict to wait for (anything |
| +// under the apps domain, every "*." row), for the same reading. Only an |
| +// explicit false withholds a name from the warm set (#724): the record may |
| +// not exist yet, and a cached lookup of it would plant "no such name" in the |
| +// issuer's resolver for the zone's negative TTL. |
| +func DNSPointing(mark *bool) bool { return mark == nil || *mark } |
| + |
| // HostAssets is the decoded assets block: the path prefixes the host's |
| // serving builds declare, the instance's asset generation, the host's |
| // authority time in Unix seconds, and the primary route hostname the block |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index 63c584807..3fedae8b9 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -114,6 +114,29 @@ type edgeHost struct { |
| // box (CARLOS_ASSET_CACHE=1) for a host assetPolicy says catches. |
| // Additive (omitempty): a file without it parses byte-identically. |
| Assets *edgeAssets `json:"assets,omitempty"` |
| + // DNSPointing is this box's own DNS verdict for a custom name, one |
| + // outside the apps domain (#724): true once the box's DNS sweep has |
| + // stamped the name "pointing", false until then. The issuer's cert warm |
| + // leaves a false name out of its set, so its caching resolver is first |
| + // asked about the name after the record exists. Set by dnsPointingMark: |
| + // nil, and so absent, on every name with no verdict to wait for. A |
| + // reader takes absent as pointing (edgesfile.DNSPointing). Additive |
| + // (omitempty on the pointer, so false is written and nil is not). |
| + DNSPointing *bool `json:"dns_pointing,omitempty"` |
| +} |
| + |
| +// dnsPointingMark is a published name's dns_pointing mark. A name under the |
| +// apps domain, a "*." row, and every name on a box with no apps domain (its |
| +// DNS sweep never runs, so nothing would ever stamp "pointing") get no mark: |
| +// their publication is exactly what it was. A custom name gets pointing as |
| +// given: an alias is published only once it is pointing, and a route says |
| +// whether its dns_status is "pointing". |
| +func dnsPointingMark(appsDomain, host string, pointing bool) *bool { |
| + host = strings.ToLower(host) |
| + if appsDomain == "" || strings.HasPrefix(host, "*.") || host == appsDomain || strings.HasSuffix(host, "."+appsDomain) { |
| + return nil |
| + } |
| + return &pointing |
| } |
| // hostOwner folds the owners of every route served under one hostname. Any |
| @@ -630,6 +653,9 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| } |
| forwards := map[string]bool{} |
| pools := provisionTickConfig(os.Getenv).ServedPools() |
| + // The apps domain as the DNS sweep reads it (domainsLoop): a name outside |
| + // it is a custom name and carries a dns_pointing mark (#724). |
| + appsDomain := strings.ToLower(strings.TrimSpace(os.Getenv("PLATFORM_APPS_DOMAIN"))) |
| for _, r := range routes { |
| // edge.Reload (internal/edge/edge.go) is the deployment's own |
| // definition of "serves": it skips any row whose Status != "ready" |
| @@ -690,6 +716,13 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // homes from its checkout replicas. See the replica loop below for |
| // the account apex that rides along. |
| h := edgeHost{Role: "home", Platform: r.Platform || r.Provisioned, Replica: r.Replica} |
| + // A route with a custom hostname (a first-route claim) is published |
| + // whatever its DNS, as it always was, and now says whether this box |
| + // has seen it pointing. dns_status is outside the registry |
| + // fingerprint, so the flip to "pointing" reaches the file on the |
| + // timer's pass, as an alias's does: the body differs from the last |
| + // one written, and the gate below writes it. |
| + h.DNSPointing = dnsPointingMark(appsDomain, r.Host, r.DNSStatus == "pointing") |
| if lifetimes { |
| // The row's lifetime pair (self-serve moves plan 1, design |
| // §6.4): the edge orders two unstamped entries by it. |
| @@ -812,8 +845,10 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| // off), and names the primary as its target: the edge compares two |
| // aliases' pairs only for one target. |
| p := hosts[primary] |
| + // Only a pointing alias reaches here, so its mark is always true. |
| hosts[a.Alias] = edgeHost{Role: "home", Alias: true, Account: acct, App: app, Stamp: p.Stamp, |
| - Incarnation: p.Incarnation, ServingSeq: p.ServingSeq, TargetHost: primary} |
| + Incarnation: p.Incarnation, ServingSeq: p.ServingSeq, TargetHost: primary, |
| + DNSPointing: dnsPointingMark(appsDomain, a.Alias, true)} |
| } |
| // Replica placements (#162): a row minted from a role=replica record — |
diff --git a/internal/host/edgesfile_dnspointing_test.go b/internal/host/edgesfile_dnspointing_test.go| new file mode 100644 |
| index 000000000..d6c225e39 |
| --- /dev/null |
| +++ b/internal/host/edgesfile_dnspointing_test.go |
| @@ -0,0 +1,168 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// #724: the edges file says, for every custom name it publishes, whether |
| +// this box has seen the name's DNS point here. An alias is published only |
| +// once it is pointing, so its mark is true. A route with a custom hostname |
| +// (a first-route claim) is published at once, as it always was, with the |
| +// mark false until the DNS sweep stamps it "pointing". Names under the apps |
| +// domain and "*." rows carry no mark. |
| +// |
| +// The flip is the part that could silently not happen: dns_status is |
| +// outside the registry fingerprint, so no change pass follows it. The next |
| +// pass at all (the timer's) must still write the file, because the body |
| +// differs from the one last written. |
| +func TestEdgesFileMarksCustomNamesDNSPointing(t *testing.T) { |
| + t.Setenv("PLATFORM_APPS_DOMAIN", "apps.test") |
| + s := &putCountingStore{Store: release.NewDirStore(t.TempDir())} |
| + reg := edgesTestRegistry(t) |
| + if err := reg.Upsert(registry.Route{Host: "app.acct.apps.test", Kind: "service", Addr: "10.0.0.1:3000", Status: "ready", Platform: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + seedRoute(t, reg, "shop.example.com") |
| + seedRoute(t, reg, "*.catch.example.com") |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: "www.example.org", Host: "app.acct.apps.test", Account: "acct", App: "app", DNSStatus: "pointing"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: "fresh.example.org", Host: "app.acct.apps.test", Account: "acct", App: "app"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + var last []byte |
| + publish := func() map[string]map[string]json.RawMessage { |
| + t.Helper() |
| + if err := edgesFilePass(context.Background(), s, reg, edgesFile{Box: "annie"}, "1.2.3.4", &last); err != nil { |
| + t.Fatal(err) |
| + } |
| + body, _, err := s.Get(context.Background(), "control/edges/annie.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var f struct { |
| + Hosts map[string]map[string]json.RawMessage `json:"hosts"` |
| + } |
| + if err := json.Unmarshal(body, &f); err != nil { |
| + t.Fatal(err) |
| + } |
| + return f.Hosts |
| + } |
| + mark := func(hosts map[string]map[string]json.RawMessage, host string) string { |
| + t.Helper() |
| + h, ok := hosts[host] |
| + if !ok { |
| + t.Fatalf("%s is not published", host) |
| + } |
| + if raw, ok := h["dns_pointing"]; ok { |
| + return string(raw) |
| + } |
| + return "absent" |
| + } |
| + |
| + hosts := publish() |
| + for host, want := range map[string]string{ |
| + "www.example.org": "true", // a published alias is a pointing alias |
| + "shop.example.com": "false", // a custom route, not yet stamped |
| + "app.acct.apps.test": "absent", // under the apps domain |
| + "*.catch.example.com": "absent", // a wildcard row |
| + } { |
| + if got := mark(hosts, host); got != want { |
| + t.Errorf("%s: dns_pointing %s, want %s", host, got, want) |
| + } |
| + } |
| + if _, ok := hosts["fresh.example.org"]; ok { |
| + t.Error("an alias that is not pointing was published") |
| + } |
| + if s.puts != 1 { |
| + t.Fatalf("first pass puts = %d, want 1", s.puts) |
| + } |
| + |
| + // The DNS sweep stamps the route. The fingerprint does not move, so it is |
| + // the gate's body comparison that has to carry the flip into the file. |
| + before, err := reg.Fingerprint() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.SetDNSStatus("shop.example.com", "pointing", time.Now().Unix()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if after, err := reg.Fingerprint(); err != nil || after != before { |
| + t.Fatalf("the registry fingerprint moved on a dns_status stamp (%v): this test's premise is gone, and the route flip now has a change pass of its own", err) |
| + } |
| + hosts = publish() |
| + if got := mark(hosts, "shop.example.com"); got != "true" { |
| + t.Errorf("shop.example.com after the stamp: dns_pointing %s, want true", got) |
| + } |
| + if s.puts != 2 { |
| + t.Fatalf("puts after the flip = %d, want 2: the flip to pointing must rewrite the file", s.puts) |
| + } |
| + publish() |
| + if s.puts != 2 { |
| + t.Fatalf("puts after an unchanged pass = %d, want still 2", s.puts) |
| + } |
| + |
| + // And back: a record the customer deleted stops reading as pointing. |
| + if err := reg.SetDNSStatus("shop.example.com", "", time.Now().Unix()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := mark(publish(), "shop.example.com"); got != "false" { |
| + t.Errorf("shop.example.com after losing its record: dns_pointing %s, want false", got) |
| + } |
| +} |
| + |
| +// A box with no apps domain runs no DNS sweep, so nothing would ever stamp a |
| +// name "pointing". It publishes no mark at all, which every reader takes as |
| +// pointing: its file is byte for byte what it was before the mark existed. |
| +func TestEdgesFileOmitsDNSPointingWithoutAnAppsDomain(t *testing.T) { |
| + t.Setenv("PLATFORM_APPS_DOMAIN", "") |
| + s, reg := release.NewDirStore(t.TempDir()), edgesTestRegistry(t) |
| + seedRoute(t, reg, "shop.example.com") |
| + if err := reg.UpsertAlias(registry.RouteAlias{Alias: "www.example.org", Host: "shop.example.com", DNSStatus: "pointing"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + var last []byte |
| + if err := edgesFilePass(context.Background(), s, reg, edgesFile{Box: "annie"}, "1.2.3.4", &last); err != nil { |
| + t.Fatal(err) |
| + } |
| + body, _, err := s.Get(context.Background(), "control/edges/annie.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !strings.Contains(string(body), `"www.example.org"`) || strings.Contains(string(body), "dns_pointing") { |
| + t.Fatalf("want the alias published and no dns_pointing mark: %s", body) |
| + } |
| +} |
| + |
| +func TestDNSPointingMark(t *testing.T) { |
| + for _, tc := range []struct { |
| + apps, host string |
| + pointing bool |
| + want string |
| + }{ |
| + {"apps.test", "shop.example.com", false, "false"}, |
| + {"apps.test", "shop.example.com", true, "true"}, |
| + {"apps.test", "Shop.Example.com", true, "true"}, |
| + {"apps.test", "app.acct.apps.test", false, "absent"}, |
| + {"apps.test", "App.Acct.Apps.Test", false, "absent"}, |
| + {"apps.test", "apps.test", false, "absent"}, |
| + {"apps.test", "notapps.test", false, "false"}, // a suffix, not a label under it |
| + {"apps.test", "*.catch.example.com", false, "absent"}, |
| + {"", "shop.example.com", false, "absent"}, |
| + } { |
| + got := "absent" |
| + if m := dnsPointingMark(tc.apps, tc.host, tc.pointing); m != nil { |
| + got = map[bool]string{true: "true", false: "false"}[*m] |
| + } |
| + if got != tc.want { |
| + t.Errorf("dnsPointingMark(%q, %q, %v) = %s, want %s", tc.apps, tc.host, tc.pointing, got, tc.want) |
| + } |
| + } |
| +} |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 4667526bb..85984bf4e 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -255,7 +255,7 @@ func TestGroupNameClassCensus(t *testing.T) { |
| }{ |
| {registry.Route{}, "DemoID DemoHost DemoLifetime DemoExpiresAt ClaimOwnership WakeIncarnation Host Slug Kind Socket Addr Addrs Health Status HoldOp Incarnation ServingSeq SeedSource ImportGate AssetsOff AssetGen PagesOff LastError Stateless FleetBoxes Copies ReplicaRevision ReplicaIncarnation DBPath Version PrevVersion GoodVersion GoodDigest GoodDemand ServingVersion App Pool Region Channel Environment Tunnel FleetBox FleetLabel Assigned Moved Caps Hibernate HA Runtime Gate RateLimit Canary Replication NextDue StatusNamed Backing Unit Platform Provisioned Seed Args IdleSeconds MaxRunSeconds DNSStatus DNSCheckedAt CertExpiresAt Account Steering UpdateSettings EgressAllow Size PolicyExpiresAt BuildState Replicas Replica CreatedAt"}, |
| {provision.Record{}, "DemoClaim Demo ReplicaAssignment Coordinator ReplicaDeploy RecordSeq Acquisition Maintenance Schema Host Slug App Account Pool Region Channel CreatedAt CreatedBy FleetBox FleetBoxAt FleetBoxMoved HA Move LastMove ActiveRun Interactive RunKeys Seed Kind Addr Unit Hibernate Runtime Environment StatusNamed Addrs Health Steering Assets AssetGen Pages Gate Incarnation IncarnationMigrating MoveSeq Retired RateLimit Role Replicas Updates Major Pin InstallRequest"}, |
| - {edgeHost{}, "Role Platform Alias Replica Wildcard Account App Stamp Incarnation ServingSeq TargetHost Assets"}, |
| + {edgeHost{}, "Role Platform Alias Replica Wildcard Account App Stamp Incarnation ServingSeq TargetHost Assets DNSPointing"}, |
| {domains.Claim{}, "Acquisition RecordIncarnation OwnershipState Schema Host Account App Route CreatedAt CreatedBy Wildcard Catchall Paths Instances Placements Pending PendingUntil"}, |
| {registry.RouteAlias{}, "Alias Host Account App DNSStatus DNSCheckedAt CertExpiresAt CreatedAt"}, |
| {registry.RoutePath{}, "Host Prefix Target Account App"}, |
| @@ -459,7 +459,7 @@ var groupNameProducerInventory = map[string]string{ |
| "claimunit_binding.go:claimUnitShape.route": "f38fd6e10aba680354ee908c255fd34e731fe2d1a22fffd41ac449e8b763dd2c", |
| "claimunit_policy.go:claimUnitShapeCheck": "45f16830e5ed834995ca573a710f1e390a504b7eb78c3c0465ac70e7f306e50c", |
| "claimunit_policy.go:rootClaimRestartShape": "1d0370516c32482b1784f4bd4ab0deb042c31120d81f4dc8c417f52b24ef76ac", |
| - "edgesfile.go:edgesFileWriteClaims": "00876c0a071a68e58799e6097f7459e81fb0a9c0d200202bda257fe409db79e9", // held-requests: drain report and forced drain publish only; no name derivation |
| + "edgesfile.go:edgesFileWriteClaims": "577e7cec14583485e02efe50f53160cd626322b2ff494fc0c86fbfbd1cfac24a", // #724: dns_pointing mark on custom names only; no name or class derivation |
| "movesheldenv.go:composeHeldEnv": "17ad3714758d1c07a71375734c125496855a16ca800eb814bde58283d3a5318b", |
| "movesheldrelease_root.go:heldReleaseRoute": "10bf824edc963319a38a47b91877b865977b1dc4a27c6e7680c46704289a7df7", |
| "movesstage.go:heldReleasePublished": "edad51c04a01657b77a9fc469404db5fde51cff1f2c61e243d6a717fb6224e85", |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 41b97d8df..8f9dcfa06 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -150,3 +150,4 @@ plan14-root-reads-no-negative-prime-724.tsv ab10145ee873e26b87a653f728cd0c973759 |
| plan14-root-reads-gvisor-probe-retry.tsv 499c08fd29787c5de2aa0197c05f82f6db0ab7760eb7d980bb24211e289e4c24 |
| plan14-root-reads-billing-dash-2-pages.tsv 499c08fd29787c5de2aa0197c05f82f6db0ab7760eb7d980bb24211e289e4c24 |
| plan14-root-reads-group-roll-verb.tsv 9668105384b1abd5009d76a73e37eef7f5c358eb5b08a3d1fe35f7c411e4d200 |
| +plan14-root-reads-warm-set-published-724.tsv 158a30344d45448de74c9d6fbcc46eeab1ef76980c17a6baef3bb36e38cac00c |
diff --git a/internal/provision/testdata/plan14-root-reads-warm-set-published-724.tsv b/internal/provision/testdata/plan14-root-reads-warm-set-published-724.tsv| new file mode 100644 |
| index 000000000..f5d1a2846 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-warm-set-published-724.tsv |
| @@ -0,0 +1,8 @@ |
| +# Census overlay warm-set-published-724, written by census-propose (#369). census-ruling-warm-set-published-724, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-warm-set-published-724.md. |
| +# 1 body, 1 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 40b29dbc496093eb99be02d5088b3c52f8da9abc58db7df89ac8247c18dc3163 internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Wrap dev, HTTP and HTTPS listeners through ConfigureGroupHairpin before serving. Indirectly read protected root boot identity and group-ingress.json; kernel local/peer addresses mark local ingress, never HTTP headers. Agent edge uses verified public source for accounting; direct read sites unchanged and absent marker keeps original listeners. CI fix removes interface enumeration: local peer must match snapshot primary IPv4, an ingress IPv4 installed locally by root, or loopback; kernel destination must still be an ingress EIP on port 80/443. Merge 45cebde4 retains deferred stopReplicaProbes alongside group listener wrapping and shutdown admission closure.;rev3=census-ruling-demo-api-site-route;basis=Change the startup failure context from load routes to initialize because origin validation now runs during construction. Existing five read sites unchanged; no new read or runtime authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Invoke the agent shutdown timestamp hook synchronously at SIGTERM/SIGINT receipt before closing admission in dev and TLS paths. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: registers the https and http servers with the connection drain (conns.serve) so a drain can close idle keep-alive connections; no read added;rev3=census-ruling-warm-set-published-724;basis=#724: the inline cert warm construction (newCertWarm over warmSet and dnsGate, then OnReload and setServedWake registering warm.nudge) moves unchanged into the new Edge.newIssuerWarm in certwarm.go and is called here with the same apps domain, parents, perHostCert, warmResolver, edgeIPs and store; the loop still starts here. The warm set it wires now reads the published edges files through the home map (OwnServedHosts and ServedHosts, both already polled) instead of the local route table, regional names aside. It is a different source, not a subset: an attached name not yet published as pointing is no longer listed, while a name the route table has already dropped stays listed until this box's next edges file write and the home map's next poll catch up (HostPolicy still refuses an order for a name the registry no longer holds). A name published not pointing is not a warm candidate at all, whether or not its certificate is cached: the warm neither looks it up, orders it nor re-arms its renewal until its home box publishes it pointing again (a cached certificate keeps serving and re-arms on a handshake at the issuer). The warm reads the set only after the issuer gate, and the read is in memory (route table and the home map's last snapshot); it also drops a DNS-miss entry for a name that has left the set before probing it. It keeps a failure record while any box publishes the exact name (the home map DeployedHosts: every box's file, own included, pointing or not, the same in-memory snapshot) or the name is a regional route-table name, and prunes it only once no box publishes it. That retention set has no apps-domain or wildcard filter (those stay on candidacy only), so a name published not pointing, or one a wildcard parent starts covering, keeps the record that explains its backoff; the set is never a source of candidates. No read site added in this unit, same 5 sites. data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 2dc64b1405b94ea073dcef2714368eb00a0b3e6738c319847f59aecb24e159cd |
| +internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Wrap dev, HTTP and HTTPS listeners through ConfigureGroupHairpin before serving. Indirectly read protected root boot identity and group-ingress.json; kernel local/peer addresses mark local ingress, never HTTP headers. Agent edge uses verified public source for accounting; direct read sites unchanged and absent marker keeps original listeners. CI fix removes interface enumeration: local peer must match snapshot primary IPv4, an ingress IPv4 installed locally by root, or loopback; kernel destination must still be an ingress EIP on port 80/443. Merge 45cebde4 retains deferred stopReplicaProbes alongside group listener wrapping and shutdown admission closure.;rev3=census-ruling-demo-api-site-route;basis=Change the startup failure context from load routes to initialize because origin validation now runs during construction. Existing five read sites unchanged; no new read or runtime authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Invoke the agent shutdown timestamp hook synchronously at SIGTERM/SIGINT receipt before closing admission in dev and TLS paths. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: registers the https and http servers with the connection drain (conns.serve) so a drain can close idle keep-alive connections; no read added;rev3=census-ruling-warm-set-published-724;basis=#724: the inline cert warm construction (newCertWarm over warmSet and dnsGate, then OnReload and setServedWake registering warm.nudge) moves unchanged into the new Edge.newIssuerWarm in certwarm.go and is called here with the same apps domain, parents, perHostCert, warmResolver, edgeIPs and store; the loop still starts here. The warm set it wires now reads the published edges files through the home map (OwnServedHosts and ServedHosts, both already polled) instead of the local route table, regional names aside. It is a different source, not a subset: an attached name not yet published as pointing is no longer listed, while a name the route table has already dropped stays listed until this box's next edges file write and the home map's next poll catch up (HostPolicy still refuses an order for a name the registry no longer holds). A name published not pointing is not a warm candidate at all, whether or not its certificate is cached: the warm neither looks it up, orders it nor re-arms its renewal until its home box publishes it pointing again (a cached certificate keeps serving and re-arms on a handshake at the issuer). The warm reads the set only after the issuer gate, and the read is in memory (route table and the home map's last snapshot); it also drops a DNS-miss entry for a name that has left the set before probing it. It keeps a failure record while any box publishes the exact name (the home map DeployedHosts: every box's file, own included, pointing or not, the same in-memory snapshot) or the name is a regional route-table name, and prunes it only once no box publishes it. That retention set has no apps-domain or wildcard filter (those stay on candidacy only), so a name published not pointing, or one a wildcard parent starts covering, keeps the record that explains its backoff; the set is never a source of candidates. No read site added in this unit, same 5 sites. data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 2dc64b1405b94ea073dcef2714368eb00a0b3e6738c319847f59aecb24e159cd |
| +internal/host/edgesfile.go edgesFileWriteClaims authority F,J1 rev3=census-ruling-self-serve-moves-1;basis=root-route;kept=F;scope=protected-decision-only; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): region-ha-2a's body, which with the box's lifetimes switch on also publishes each served row's lifetime pair (registry:Incarnation and registry:ServingSeq, two new sites on the rows it already lists) and an alias's or served catch-all's primary's pair, and names that primary as target_host whatever the switch; a report the edge orders unstamped entries by, not a decision; no record, /data, release or claim read added; F,J1 authority retained; self-serve moves 1 Task 8;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 8: takes a localAddrs reader (instancectl.LocalAddresses in production, which reads /proc/net/fib_trie and /proc/net/if_inet6 in the agent) and publishes its non-loopback entries as the edges file's addrs before the write gate (boxAddrs, no read of its own), so an address change writes once. The same 44 sites, offsets moved; no record, /data, release or claim read added; a report the console's egress grant check reads, not a root decision; F,J1 authority retained.;rev3=census-ruling-edge-asset-cache-3;basis=starts with assets = assets.active(), so a policy whose box has not opened its asset store publishes no assets blocks and reads no manifests, and copies the decision's Primary (the route host the block was decided for, drift D4) into the published assets block; read sites unchanged (44); no read added. Merged onto main's #328 body, which takes the localAddrs reader: the assets.active() line sits after that signature and the loop passes pub and instancectl.LocalAddresses;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the claims argument (*edgesClaims) becomes addrs (AddressSource) and the applyEdgesClaims(ctx, claims, routes, hosts) call is deleted with edgesclaims.go, which is the one whole:Route site removed: no host claim is read and every served row publishes as with region HA off; the box-address publication is the same code reading addrs.BoxAddresses() instead of claims.addrs; a report the edge reads, not a root decision; no read added; merge of origin/main d7ae1d76: main's edge asset cache plan 3 body is kept (census-ruling-edge-asset-cache-3): the first line is assets = assets.active(), so a policy whose store has not opened publishes no assets blocks and reads no manifests, and edgesFileLoop passes pub (assets.active() for that tick) in the assets argument; main's claims *edgesClaims argument is this branch's addrs AddressSource, and no edgesClaims, applyEdgesClaims or hostclaim reference remains;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: skips publishing a platform alias edge.PlatformAliasFold refuses (and so anything attached to it); reads the same route listing;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 and its fix rounds: publishes by FleetArmVerdict (via fleetRefusedFor): withheld rows left out; a forward host's path rows left out of its owner; no assets for forward rows; the alias loop replays Reload's alias fold from the served rows so a chained alias carries its root primary's owner; certRefused and parentRefused leave out a refused claim's wildcard parent (+registry:Alias x5, +registry:Host x4, +whole:Route, +whole:RouteAlias x2, +whole:RoutePath x7, +whole:WildcardDomain). Rows already read in the pass; keeps authority F,J1; publishes less, never more.;rev3=census-ruling-probe-burst-limit;basis=sets the constant BurstNotices=true on the box's own edges file (this build's edge answers probe-burst notices, so peers may send them); not from config or any read; the same 65 sites; a report other edges read, not a root decision; F,J1 authority retained; no new root read or write kind;rev3=census-ruling-region-ha-p3a;basis=Publish one injected role snapshot with box_role/admitted/drained; retain legacy route and alias rows during booting, cutting namespace withdrawal under the 2026-11-04 ruling; acknowledge the exact published tuple only after PUT; existing registry reads unchanged.;rev3=census-ruling-region-ha-p2b;basis=region HA P2b-1 T0 (Q1 ruling): before building the comparison copy and the body, a nil NamedPools on the identity becomes []string{} so the additive named_pools field is always an explicit array; the list itself is computed once at arm by edgesFileEligibility from the same provisionTickConfig(os.Getenv) parse as serves_shared_pool (CARLOS_POOLS through provision.ParseBoxPools, filtered to nonempty provision.ValidPool names, sorted, unique). A report the console reads for create admission, not a root decision; no record, /data, release or claim read added; read sites unchanged (65); F,J1 authority retained. One-off cost: the first pass after the upgrade writes once per box (seeded gate null vs []).;rev3=census-ruling-region-ha-p3b;basis=Require cached GroupReadersReady before first group publication and append additive names-2 capability even for supplied identities. Agent writes the same edges object/index with existing registry reads; known readers come from root boot configuration, snapshot from existing fold, no added GET/LIST or root authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Omit non-forward, non-platform-alias rows outside local served pools from home publication; added Host/Pool field reads and local configuration use, existing registry/store operations retained.;rev3=census-ruling-edge-page-cache-1;basis=prunes the manifest cache through the new atomic pointer (assets.manifests.Load().prune(...), nil-safe); nothing else changes; read sites unchanged (67); no read added;rev3=census-ruling-region-ha-held-build;basis=writes also when DrainPublishRequired, and reports the written drain state, its ha_drain mark (transaction and publication id) and generation to DrainSource (in-memory); the file gains ha_drained and ha_drain beside the existing draining; no read added. held-requests Task 4: sets the constant ha_take=1 on the box's own file when its in-memory capabilities include region-ha-1 (this build's edge answers take requests); not from config or any read; a report other edges read, not a root decision; no read added;rev3=census-ruling-warm-set-published-724;basis=#724: the agent as carlos: reads PLATFORM_APPS_DOMAIN from the environment once per pass (the variable domainsLoop already reads) and sets an additive dns_pointing mark on each published custom name through dnsPointingMark: true on a published alias (registry:Alias, already published only when its dns_status is pointing), and on a route with a hostname outside the apps domain whether its registry:DNSStatus is pointing (registry:Host, registry:DNSStatus on rows the pass already lists). No mark under the apps domain, on a wildcard row, or with no apps domain set. A report the issuer cert warm reads to leave a not-yet-pointing custom name out of its set, not a root decision; it publishes the same names as before. No record, /data, release or claim read added; no new registry query; F,J1 authority retained. One-off cost: the first pass after the upgrade writes once on a box homing a custom name. registry:Account@16743,registry:Alias@10183,registry:Alias@10340,registry:Alias@10410,registry:Alias@10442,registry:Alias@11186,registry:Alias@11396,registry:Alias@14216,registry:Alias@14266,registry:Alias@9544,registry:Alias@9563,registry:Alias@9662,registry:Alias@9716,registry:Alias@9751,registry:Alias@9813,registry:App@16755,registry:DNSStatus@10349,registry:DNSStatus@5731,registry:DNSStatus@9858,registry:Host@14119,registry:Host@14139,registry:Host@14404,registry:Host@14484,registry:Host@14519,registry:Host@14568,registry:Host@15030,registry:Host@15065,registry:Host@16173,registry:Host@4188,registry:Host@4279,registry:Host@4325,registry:Host@4384,registry:Host@5723,registry:Host@5970,registry:Host@6940,registry:Host@9589,registry:Host@9637,registry:Incarnation@5930,registry:Platform@5238,registry:Pool@4239,registry:Provisioned@5252,registry:Replica@5276,registry:ServingSeq@5945,registry:Status@2957,whole:Route@1026,whole:Route@18213,whole:Route@1841,whole:Route@19038,whole:Route@19213,whole:Route@2327,whole:Route@7025,whole:Route@750,whole:RouteAlias@14170,whole:RouteAlias@18235,whole:RouteAlias@19228,whole:RouteAlias@9427,whole:RouteAlias@9509,whole:RouteAlias@9701,whole:RoutePath@18228,whole:RoutePath@19221,whole:RoutePath@6809,whole:RoutePath@6841,whole:RoutePath@6888,whole:RoutePath@6916,whole:RoutePath@6954,whole:RoutePath@6974,whole:RoutePath@6986,whole:RoutePath@7040,whole:WildcardDomain@14097,whole:WildcardDomain@14473 5b2180cec383f62ccb24a32a8eff30ab462eaab4d13f4b7b0503fc639a0c6b49 |
| +@coverage internal/edge 80e3a4773d48410981cb28be98dfc67414dd727db47a6a9b21a0a8e92bba568f |
| +@coverage internal/edgesfile 55e261de1c2527dade77aefaefd3515595bfccb7c6bbaeec246c5ab1308047dc |
| +@coverage internal/host 6e65359f159ffa837e000c1506df6545f7f47857a0e29f73338c0b0338d50201 |