carlos / platform Public

console: exclude group edges from DNS and unrelated size limits

Exclude pool-only boxes and proven group members from console DNS
addresses so disposable public IPs are not offered or written to bought
zones. Bound instance sizes by the record's region and pool, requiring
fresh host evidence and using the app pool before its first instance.

Guard the existing group boot-to-writer contract and document all edges
readers, steering's publication dependency, and the deferred C4/C13 work.
Correct the fixed-box alias test fixture to publish shared-pool service.

Validation: full console suite and Task 5 host regressions pass. Full host
retains 21 baseline failures and one intermittent offline-move failure;
the census reports 17 existing branch discrepancies outside this change.
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 347e60939db9f4a1d889d4c1a50d95daf6b50e1e parent 2a7ed4d
9 files changed, +532 −41
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +108 −0
  • internal/console/apiplacements.go +3 −1
  • internal/console/edgesdns.go +18 −0
  • internal/console/edgesreaders_g3_test.go +242 −0
  • internal/console/policysize.go +61 −17
  • internal/console/policysize_test.go +9 −9
  • internal/console/server.go +23 −12
  • internal/host/aliasesread_e2e_test.go +2 −2
  • internal/host/edgesfile_group_guard_test.go +66 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>bhu81n8cd</task-id> <tool-use-id>toolu_01SsEr9JFU9GeX7xuYLSFwSc</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/f72ef775-81b3-4d2e-a18d-c8edb14aa192/tasks/bhu81n8cd.output</output-file> <status>completed</status> <summary>Background command "sleep 15; .superpowers/sdd/2026-11-07-region-ha-g3-fixes/wait.sh t8" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bunn337el</task-id> <tool-use-id>toolu_01EbFDdN429e1ATDfL525uFx</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/f72ef775-81b3-4d2e-a18d-c8edb14aa192/tasks/bunn337el.output</output-file> <status>completed</status> <summary>Background command "sleep 15; .superpowers/sdd/2026-11-07-region-ha-g3-fixes/wait.sh t6f1" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a6c527db187a5eba6</task-id> <tool-use-id>toolu_01HKxKST3rDT1hBJaQvHXQuB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/f72ef775-81b3-4d2e-a18d-c8edb14aa192/tasks/a6c527db187a5eba6.output</output-file> <status>completed</status> <summary>Agent "Scoped re-review T6 fix round" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>No P1 and no P2 in this fix round. All five findings are addressed, and I found no way for the edges file to be deleted or the receipt acked before every host the dead box owned or released is adopted or superseded. There are two new P3s, both about liveness margins rather than safety. ## Per-finding verdicts - **P1 (listing root vs the scanner's key): ADDRESSED.** - `internal/host/hadepartures_scan.go:384-394` takes the root from `path.Dir(c.cfg.Prefix(probe))` and refuses an empty root or `"."`. - It checks `Prefix(h.Host) == root+"/"+h.Host` for every current record on every pass. The check runs before the cache is used (`:395`), so a record added mid-walk is checked too. Any mismatch gives a nil set, the full walk and a log line. - `internal/lease/ha.go:220-222` now takes the root as an argument. - Production-wired test: `TestDepartureG3PrefixSafety` covers roots `fleet` and `""`, each with the lock held and released. `newG3Departure` sets `a.Backend.Cfg.Prefix`, and the wiring closure in `hadepartures_wiring.go:113` reads it. The report shows the negative control failing as expected. - `TestDepartureLockListingPrefixMismatch` covers a single record that does not match. - **P2-a (delimiter listing): ADDRESSED.** - `ha.go:222-230` lists `root+"/"` with `Delimiter "/"` and keeps only CommonPrefixes. Any failed page returns nil. - The bound is now 15 s (`hadepartures_scan.go:403`). - The lease test adds 2000 non-lock objects and a directory that holds only non-lock objects. - **P2-b (80 locked hosts, higher cap): ADDRESSED.** - The cap is 128 when a listing succeeded and 32 otherwise (`:166-168`, used at `:181`). - `TestDepartureG3FiveMinutes` gains `live=80` variants, with the locks split between live-owned and released. All three departures finish and are acked in 2m30s, with 480 unrelated reads (6 walks × 80). - `TestDepartureRequestBudget` now runs both the listed and unlisted cases with explicit numbers. - **P3, LockPrefixes not persisted: ADDRESSED.** The fields are removed from `internal/registry/ha_scan.go:25-41`, and the listing is held in memory in `c.lockListings`. `TestDepartureLockListingResume` (restart case) checks it relists and that nothing is persisted. - **P3, relist after a blocked backoff: ADDRESSED** at `hadepartures_scan.go:162-164`. Here `d` holds the code the previous pass ended with, because it is loaded before the reserve write. - **P3, one fallback log per walk: ADDRESSED.** A failed listing is cached as nil for the rest of the walk (`:395-414`). The tests now expect two log lines for two walks. ## Safety check on the fix diff - **The gate:** host names cannot contain `/`, `..`, upper case or be empty. `launchctx/controlname/names.go:18` only allows dot-separated DNS labels. - Even an invalid host is blocked before an absent record is skipped: the `ValidHostShape` block runs at `hadepartures_scan.go:197`, ahead of `if absent { continue }`. - A prefix of `""` gives root `"."` and is refused. - A prefix of `"/"` gives root `"/"`, but every record then fails the equality (`"/h"` against `"//h"`), so it is refused. - `"./x"` and `"x/"` are cleaned by `path.Join` on both the read side and the probe, so they stay consistent. - **Delimiter semantics:** - A host directory that holds only `lock.json` still appears as a CommonPrefix. - A host whose name is a prefix of another, such as `a.example.com` and `a.example.com.au`, gives two separate `root/&lt;host&gt;/` entries, matched exactly after the trailing `/` is trimmed. - Pagination uses the SDK paginator, and any page error discards the whole set. - A timeout during the listing is an error, so it falls back to the full walk. - The listing is a superset of hosts with a lock, so it can only cause extra reads, never skipped ones. - **Higher cap and request budget:** one LIST per walk, or per pass while blocked, plus at most 128 GETs per pass. The total reads per walk are unchanged. - **No persisted listing across a restart:** after a restart the evidence map is empty. The departure is observed again and drops to `pending`, which starts a new walk (`:105-124`, `:137-145`). A relist always happens after the termination proof, and hosts seen before are always read. - **Relist after a blocked backoff:** this only adds reads for hosts not yet visited. Visits are kept, and blocked hosts are retried on the next walk as before. - **Liveness:** I found nothing that can block forever under normal conditions. Edges are kept whenever a pass is cut short. ## New findings in the fix diff - **P3, smaller latency margin per pass.** `ScanPass` has a 30 s deadline (`:91`). When that deadline hits, the loop breaks at `:181` and the pass returns `scan_timeout` at `:333` without calling `SaveDepartureScan`, so every read after the last pre-adoption save (`:309-312`) is lost. - With 128 reads per pass, the walk stops making progress once the average GET takes more than about 230 ms. On a pass that also spends the full 15 s listing (the first pass of a walk, or every pass while blocked), the limit is about 120 ms. At 32 reads the limit was about 940 ms. - This is safe because the edges are kept, and it is unlikely in-region. Saving visits on timeout, or capping reads by the time left, would remove the cliff. - **P3, the five-minute proof flatters the listing.** Because the listing now returns any host directory, a production host that has litestream or files data is always listed. In practice all ~260 hosts get read: 3 passes of 128 per walk, so about 6 passes (roughly 3 minutes) per departure. - That should still be under 5 minutes, but no test models every host having a directory. The `live=80` variant leaves 179 hosts with no objects at all. ## Verification - The focused `-run` tests pass: PrefixSafety, LockListing (including PrefixMismatch and Resume), RequestBudget, FiveMinutes (all four variants), ListingDenied, Simulation, ProductionImporter, RollbackCheckpoint, G3Production, FixedRetained, DeletionRace and FairScheduling. - `TestListDepartureLocks` in `internal/lease` passes. - I ran the host package unsandboxed because the default Go cache is read-only inside the sandbox. `GOCACHE` stayed at its default, and the scratch `TMPDIR` was removed. ## Deferred (out of scope) - `c.lockListings` entries for departures that leave without going through the deletes at `:145`, `:359` or `:366` are never freed. This is a tiny memory leak. - The implementer's report shows the root-read census failing on `hadepartures_scan.go:Controller.ScanPass` and the region-host infra. It needs the census overlay and an approval before merge. - The report's full host suite has many "hostwrite: lifecycle provider unavailable" failures in the claim-binding tests. These look environmental and unrelated to this diff, but I did not check them. Files: `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-g3-fixes/internal/host/hadepartures_scan.go`, `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-g3-fixes/internal/lease/ha.go`, `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-g3-fixes/internal/host/hadepartures_listing_test.go`.</result> <usage><subagent_tokens>100460</subagent_tokens><tool_uses>22</tool_uses><duration_ms>847109</duration_ms></usage> </task-notification>

Attributed to this commit: 30.7 g CO₂e (3,923,549 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-g3-fixes, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md
index 89aba4c6f..2fc7c23b2 100644
--- a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md
+++ b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md
@@ -812,3 +812,111 @@ None.
**Dev.** Dev's IE entry carries no `ha_pools`, so dev behaves exactly as today: plain home creates are born HA, pooled and non-home HA data creates get F5, and existing records (hapair-a1) keep their immutable flag.
**Review budget.** One Astra review of this addendum with its plan, at most three rounds (stopping rules). Round 1 (A1-A5, NOT READY) is answered in this text: the scoped proof always uses the configured bucket (A2), needs the activator prefix (A1), `--from` is unchanged (A3), and an invalid config is a 503 (A4). Round 2 (A6, A7) adds I-B10's storage gate and the Retry-After header on the proof's 503s.
+
+## 24. Readers of edges files
+
+Every platform box writes `control/edges/<ref>.json` through
+`internal/host/edgesfile.go`. Readers must distinguish routing evidence
+from evidence that a box is a stable DNS target or can run a particular
+record. The G3 audit found readers treating members as steering targets,
+permanent hostname-history targets, DNS addresses and size limits for
+unrelated pools. Housekeeper candidacy had the same membership fault,
+though its inputs are local configuration rather than edges files.
+
+### 24.1 What a member's file is
+
+A group member may publish hosts, including platform hosts, or no hosts.
+Aliases and wildcards appear only when it serves them. Its `eip` is an
+auto-assigned public address used for box traffic, not a stable ingress
+address. Replacement releases that address. After termination the file
+stays unchanged until the departure removes it (§9.3). Liveness comes from
+status reports, bounded generation age where required, and failed dials.
+
+The `g-` name shape does not prove membership. A fixed label may have that
+shape. The capacity observation verifies the signed identity and binds the
+reference to its account and instance, rejecting conflicting files. Readers
+that need membership reuse that proof. Pool evidence answers a different
+question: whether a box can run a record in a given pool.
+
+A member must publish `serves_shared_pool:false`. The group boot constructor
+(`hostenv.AssembleGroup`) requires named pools and refuses an empty pool or
+`@shared`; the writer derives eligibility from the same reconcile
+configuration. A console region being unscoped under §23 does not change
+this box-side boot rule. The writer guard test runs the boot constructor,
+eligibility parser and actual publication pass together.
+
+Steering currently has no cached identity evidence in its pass. Proving
+membership there would need additional identity reads. It therefore relies
+on the publication rule above and excludes files that say
+`serves_shared_pool:false`. Supporting shared-pool group boot would require
+changing steering to exclude proven members or use stable ingress before
+relaxing that rule. It must never infer membership from the name alone.
+
+### 24.2 The readers
+
+The IDs match the G3 edges-reader audit. A member-aware reader uses pool or
+identity evidence to treat members differently. A member-blind reader has
+the same rule for every box.
+
+| ID | Reader | Rule and stale-file behavior |
+|---|---|---|
+| E1 | Edge home map poll (`internal/edge/homemap.go`) | Blind mirror, including last-good files after failed reads. |
+| E2 | Name fold, routing and backhaul | Blind: member hosts are real routes. A dead holder fails its dial; retries and the holder cache select alternatives until departure removes the file. |
+| E3 | Wildcard parents, served names and certificate warming | Blind: derive names from the published hosts. Names may linger until retirement. |
+| E4 | View and holder checks (`holderview.go`) | Blind: members are serving peers (§4.3); generation freshness bounds stale evidence. |
+| E5 | Cold-wake and duty placement (`wakeplacement.go`) | Aware through pool evidence and fresh headroom. Only a box serving the route's pool may wake it. |
+| E6 | Probe-burst notices | Blind: notify published non-wildcard hosts. Failed dials have a bounded queue. |
+| E7 | Certificate settle peer check | Blind: a member is a peer. |
+| E8 | Group reader inventory and names-2 latch | Aware through name shape only in the restrictive direction: a false positive raises the release floor. A stale file counts until retired. |
+| E9 | Departure observations | Aware through identity, termination proof, exact key and ETag. Delete only after the required scan (§9.3). |
+| H1 | Steering (`internal/steering`) | Aware through shared-pool exclusion, with one target per AWS region. Depends on §24.1's publication rule, including for stale files. |
+| H2 | Host alias pass (`DeploymentRoutesComplete`) | Blind: live member routes reserve names. Stale status removes them from this fold. |
+| H3 | Agent and edge “pointing at us” (`EdgeIPs`) | Blind: member addresses widen accepted destinations while status is fresh. This is not DNS advice. |
+| H4 | Move targets, fleet report and T8 | Blind: members make the one-box check refuse. HA regions refuse moves (N-HA4). |
+| H5 | Relocation chooser | Aware through shared-pool eligibility and freshness. Named-pool members are excluded. |
+| H6 | Enrollment reference reuse | Blind: any file reserves its reference, regardless of liveness. |
+| C1 | Console capacity observation and EligibleBoxes metric | Aware through identity, pool and status. Stale boxes are excluded from capacity but remain evidence for the storage gate (§23). |
+| C2 | Hostname history and hosts-used activation roster | Aware through the observation's membership proof. A proven member's disposable disk is not a permanent history target. |
+| C3 | Automatic region eligibility | Aware through `serves_shared_pool`: members neither admit nor veto a shared-pool region; stale boxes are skipped. |
+| C4 | Explicit-region gate and move placements | Must become pool-aware in §13's plan. Today it ignores `serves_shared_pool:false`; a region containing only members can wrongly admit a shared-pool create. A fixed shared-pool box currently masks this defect. |
+| C5 | Instance list “served by” | Blind display: lists member hosts, including dead members until retirement. |
+| C6 | Claims executor chooser | Aware through shared-pool eligibility and freshness, as H5. |
+| C7 | Move selection and release floor | Blind: every file must meet the floor, including stale members. HA regions refuse moves. |
+| C8 | Offline moves | Aware through shared-pool exclusion. HA regions also refuse moves. |
+| C9 | Seeds readiness and demo claims | Seeds count every box toward the release floor and one-box rule; stale boxes leave readiness unconfirmed. Demo claims use shared-pool boxes. HA regions refuse imports. |
+| C10 | Database read forwarding | Blind: requires the published capability, whoever serves it. |
+| C11 | Instance size door (`policysize.go`) | Aware through `served_pools`. Fresh boxes count when region and pool match a record, or they publish its host. A stale host claim never counts. With no records, use the app manifest's pool across regions. Unknown or malformed pool evidence retains inclusion. |
+| C12 | Lifetimes cutover and watch | Blind: every file needs the release floor and fresh status. A stale member blocks until retired. |
+| C13 | GeoIP readiness | Blind readiness check: members serve traffic and need GeoIP. A stale file blocks. The remedy text suggesting manual deletion is deferred; member files require the departure protocol. |
+| C14 | Egress grants and fleet-address report | Blind: all published addresses conservatively refuse an allow, including stale files. |
+| C15 | DNS guidance, domain placements and purchased-zone apex | Aware: suppress addresses from files publishing `serves_shared_pool:false` or bound to proven members by the capacity observation. Reuse the proof without new identity reads. Configured ingress still replaces box-derived DNS addresses. Status freshness excludes dead boxes; a complete empty refresh clears cached addresses. |
+| C16 | Console and CLI region names | Blind: any member can name its AWS region. |
+| C17 | Asset status home election | Blind, with the same member routing rules as E2. |
+| C18 | Domain attach conflict check | Blind: live member routes reserve names, as H2. |
+| Scripts | Group roll and boot witness | Aware operator tools: inspect members by reference and check that a completed witness left no member files. |
+
+For C11, actual fresh host publication keeps a box in the size check even
+when its declared pool excludes the record. Missing or unreadable record
+sets retain the all-box check. An unreadable app manifest cannot narrow the
+set. Fleet roster handling is unchanged.
+
+For C15, proof unavailable means there is no identity-based exclusion;
+explicit shared-pool exclusion still applies. An unproven `g-` label alone
+never removes a fixed address. The configured public ingress and explicit
+edge-address lists remain operator-owned stable address inputs.
+
+### 24.3 The rule for a new reader
+
+A new reader states in its doc comment and this table whether it is
+member-aware or member-blind, and why. It must not assume that an edges file
+carries hosts, aliases or wildcards, that its box is a steering target or a
+stable ingress address, that its box contends for the housekeeper lease,
+or that it serves the shared pool. It must not use the `g-` name shape to
+grant authority or to exclude a fixed box from DNS.
+
+The reader states what happens to a terminated member's unchanged file.
+Its tests include member and stale-member files beside fixed boxes, through
+the production constructor and handler or pass. Pool-specific readers also
+exercise unknown evidence so old writers retain their behavior. DNS
+readers exercise missing configured ingress; configuration alone must not
+be the protection against publishing disposable member addresses.
diff --git a/internal/console/apiplacements.go b/internal/console/apiplacements.go
index 993a68e34..8a8ebefc3 100644
--- a/internal/console/apiplacements.go
+++ b/internal/console/apiplacements.go
@@ -131,7 +131,8 @@ func (s *Server) handleAPIDomainPlacementsGet(w http.ResponseWriter, r *http.Req
writeJSON(w, http.StatusOK, s.placementsView(*c, snap, boxes, now))
}
-// placementsView is the GET body from one claim and one joined snapshot. Pure.
+// placementsView is the GET body from one claim and one joined snapshot.
+// Address filtering uses the existing capacity observation without store reads.
//
// Single mode has one entry, the route's: every fresh box publishing the
// target under home is listed, whatever its placement, and counts when it
@@ -139,6 +140,7 @@ func (s *Server) handleAPIDomainPlacementsGet(w http.ResponseWriter, r *http.Req
// claim, which every release serves (controller ruling). A regional claim
// answers regionalPlacementsView.
func (s *Server) placementsView(c domains.Claim, snap edgesfile.Snapshot, boxes []status.Box, now time.Time) placementsAnswer {
+ snap = s.dnsAddressSnapshot(snap)
if c.Regional() {
return s.regionalPlacementsView(c, snap, boxes, now)
}
diff --git a/internal/console/edgesdns.go b/internal/console/edgesdns.go
new file mode 100644
index 000000000..c9db4624f
--- /dev/null
+++ b/internal/console/edgesdns.go
@@ -0,0 +1,18 @@
+package console
+
+import "github.com/carlosframework/platform/internal/edgesfile"
+
+// dnsAddressSnapshot is member-aware: pool exclusions and the capacity
+// observation's identity proof prevent disposable addresses reaching DNS.
+// Routing and other box readers still use the original address. Membership
+// proof uses the existing observation and performs no bucket reads here.
+func (s *Server) dnsAddressSnapshot(snap edgesfile.Snapshot) edgesfile.Snapshot {
+ files := append([]edgesfile.PlacementView(nil), snap.Files...)
+ for i, f := range files {
+ if isFalse(f.ServesSharedPool) || s.provenGroupTarget(snap, f.Placement, "box:"+f.Box) {
+ files[i].EIP = ""
+ }
+ }
+ snap.Files = files
+ return snap
+}
diff --git a/internal/console/edgesreaders_g3_test.go b/internal/console/edgesreaders_g3_test.go
new file mode 100644
index 000000000..fa98deb52
--- /dev/null
+++ b/internal/console/edgesreaders_g3_test.go
@@ -0,0 +1,242 @@
+package console
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/edgesfile"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+ "github.com/carlosframework/platform/internal/zonehost"
+)
+
+func putG3Edges(t *testing.T, st release.Store, box, ip, pool, host string, total int64, at time.Time) {
+ t.Helper()
+ hosts := map[string]any{}
+ if host != "" {
+ hosts[host] = map[string]any{"role": "home", "platform": true}
+ }
+ named := []string{}
+ if pool != "" {
+ named = append(named, pool)
+ }
+ body, err := json.Marshal(map[string]any{"v": 1, "box": box, "box_id": box, "region": "eu-west-1", "eip": ip, "serves_shared_pool": pool == "", "served_pools": []string{pool}, "named_pools": named, "accepts_inbound": true, "hosts": hosts, "box_mem_total_mib": total})
+ if err != nil {
+ t.Fatal(err)
+ }
+ putFixtureObject(t, st, edgesfile.Key(box), body)
+ putSizeReport(t, st, box, "", at, nil)
+}
+
+func g3DNSWorld(t *testing.T, st release.Store, host string) {
+ t.Helper()
+ // A fixed box with a group-shaped label must remain an address source.
+ putG3Edges(t, st, "g-aaaaaaaaaaaaaaaaaaaa", "192.0.2.10", "", host, 8192, time.Now())
+ putG3Edges(t, st, "g-bbbbbbbbbbbbbbbbbbbb", "192.0.2.11", "hapair", host, 927, time.Now())
+ putG3Edges(t, st, "g-cccccccccccccccccccc", "192.0.2.12", "hapair", host, 927, time.Now())
+ putG3Edges(t, st, "g-dddddddddddddddddddd", "192.0.2.13", "hapair", host, 927, time.Now().Add(-time.Hour))
+}
+
+func TestG3DomainReadersExcludeMemberAddresses(t *testing.T) {
+ for _, ingress := range []bool{false, true} {
+ t.Run(map[bool]string{false: "without-ingress", true: "configured-ingress"}[ingress], func(t *testing.T) {
+ fx, token, _ := rootfsDoorWorldToken(t, "g3-dns")
+ fx.srv.cfg.EdgeIPs = nil
+ g3DNSWorld(t, fx.rel, "route.example.net")
+ attachShopClaim(t, fx, fx.sqid, "shop", "alias.example.com", "route.example.net")
+ want := "192.0.2.10"
+ if ingress {
+ fx.srv.cfg.RegionIngress = []string{ingressIP}
+ want = ingressIP
+ }
+ code, _, out := rawReq(t, http.MethodGet, domainGetURL(fx, fx.sqid, "shop", "alias.example.com"), token, "")
+ if code != 200 || !strings.Contains(out, want) {
+ t.Fatalf("guidance = %d %s", code, out)
+ }
+ for _, ip := range []string{"192.0.2.11", "192.0.2.12", "192.0.2.13"} {
+ if strings.Contains(out, ip) {
+ t.Errorf("guidance contains member %s: %s", ip, out)
+ }
+ }
+ if !ingress {
+ p := getPlacements(t, fx, token, "alias.example.com")
+ var boxes []placementsBoxResp
+ if err := json.Unmarshal(p.Placements[0].Boxes, &boxes); err != nil {
+ t.Fatal(err)
+ }
+ for _, b := range boxes {
+ if b.EIP != "" && b.EIP != want {
+ t.Errorf("placement offers member address: %+v", b)
+ }
+ }
+ if !p.Placements[0].Ready {
+ t.Fatalf("fixed box no longer ready: %+v", p)
+ }
+ }
+ })
+ }
+}
+
+func TestG3BoughtZoneExcludesMemberAddresses(t *testing.T) {
+ for _, ingress := range []bool{false, true} {
+ t.Run(map[bool]string{false: "without-ingress", true: "configured-ingress"}[ingress], func(t *testing.T) {
+ f := newPurchaseFixture(t)
+ f.srv.cfg.EdgeIPs = nil
+ g3DNSWorld(t, f.rel, "")
+ want := "192.0.2.10"
+ if ingress {
+ f.srv.cfg.RegionIngress = []string{ingressIP}
+ want = ingressIP
+ }
+ p := f.start(t)
+ f.authorise(t, p)
+ f.until(t, p.ID, PurchaseZoneReady)
+ if got := f.zone.Managed[p.Domain].Apex; !reflect.DeepEqual(got, []zonehost.ApexTarget{{IP: want}}) {
+ t.Fatalf("apex = %+v", got)
+ }
+ })
+ }
+}
+
+func TestG3SizeDoorUsesRecordAndDefaultPools(t *testing.T) {
+ for _, records := range []bool{false, true} {
+ for _, pool := range []string{"", "hapair"} {
+ name := map[bool]string{false: "default", true: "record"}[records] + "/" + pool
+ t.Run(name, func(t *testing.T) {
+ fx := newPolicyFx(t, "g3-size")
+ if err := provision.PutManifest(context.Background(), fx.rel, fx.sqid, "shop", provision.Manifest{Schema: 1, App: "shop", Domain: "example.com", Pool: pool}); err != nil {
+ t.Fatal(err)
+ }
+ if records {
+ rec := provision.Record{Schema: 1, Host: shopHost, Slug: "shop-a", App: "shop", Account: fx.sqid, Pool: pool, Channel: "stable", CreatedAt: time.Now()}
+ if err := provision.CreateRecord(context.Background(), fx.rel, rec); err != nil {
+ t.Fatal(err)
+ }
+ }
+ putG3Edges(t, fx.rel, "fixed", "192.0.2.10", "", "", 8192, time.Now())
+ putG3Edges(t, fx.rel, "g-bbbbbbbbbbbbbbbbbbbb", "192.0.2.11", "hapair", "", 927, time.Now())
+ code, _, out := fx.put(t, "shop", `{"default_size":"small"}`, policyCreate)
+ if pool == "" {
+ if code != 200 {
+ t.Fatalf("shared size = %d %s", code, out)
+ }
+ } else if code != 409 || !strings.Contains(out, "g-bbbbbbbbbbbbbbbbbbbb (927 MiB)") {
+ t.Fatalf("named size = %d %s", code, out)
+ }
+ })
+ }
+ }
+}
+
+func TestG3SizeDoorIgnoresStaleHostClaim(t *testing.T) {
+ fx := newPolicyFx(t, "g3-size-stale")
+ sizeRecord(t, fx.rel, fx.sqid, "shop", shopHost, "")
+ putG3Edges(t, fx.rel, "fixed", "192.0.2.10", "", shopHost, 8192, time.Now())
+ putG3Edges(t, fx.rel, "g-bbbbbbbbbbbbbbbbbbbb", "192.0.2.11", "hapair", shopHost, 927, time.Now().Add(-time.Hour))
+ code, _, out := fx.put(t, "shop", `{"default_size":"small"}`, policyCreate)
+ if code != 200 {
+ t.Fatalf("stale claim bounded size: %d %s", code, out)
+ }
+}
+
+func TestG3DNSExcludesProvenMemberServingSharedPool(t *testing.T) {
+ fx, token, _ := rootfsDoorWorldToken(t, "g3-dns-proof")
+ fx.srv.cfg.EdgeIPs = nil
+ ref := haGroupReference(moveTestAccount, groupTestInstance)
+ c := groupMemberCase{fx: fx, ref: ref}
+ c.observe(t, groupTestInstance, time.Now(), nil)
+ c.proven(t)
+ putG3Edges(t, fx.rel, "fixed", "192.0.2.10", "", "route.example.net", 8192, time.Now())
+ putG3Edges(t, fx.rel, ref, "192.0.2.11", "", "route.example.net", 927, time.Now())
+ attachShopClaim(t, fx, fx.sqid, "shop", "alias.example.com", "route.example.net")
+ code, _, out := rawReq(t, http.MethodGet, domainGetURL(fx, fx.sqid, "shop", "alias.example.com"), token, "")
+ if code != 200 || !strings.Contains(out, "192.0.2.10") || strings.Contains(out, "192.0.2.11") {
+ t.Fatalf("proven member guidance = %d %s", code, out)
+ }
+ p := getPlacements(t, fx, token, "alias.example.com")
+ if strings.Contains(string(p.Placements[0].Boxes), "192.0.2.11") {
+ t.Fatalf("proven member placement = %s", p.Placements[0].Boxes)
+ }
+}
+
+func TestG3DNSClearsPreviouslyEligibleAddress(t *testing.T) {
+ fx, token, _ := rootfsDoorWorldToken(t, "g3-dns-refresh")
+ fx.srv.cfg.EdgeIPs = nil
+ attachShopClaim(t, fx, fx.sqid, "shop", "alias.example.com", "route.example.net")
+ get := func() string {
+ code, _, out := rawReq(t, http.MethodGet, domainGetURL(fx, fx.sqid, "shop", "alias.example.com"), token, "")
+ if code != 200 {
+ t.Fatalf("get = %d %s", code, out)
+ }
+ return out
+ }
+ putG3Edges(t, fx.rel, "box", "192.0.2.11", "", "route.example.net", 927, time.Now())
+ if !strings.Contains(get(), "192.0.2.11") {
+ t.Fatal("initial address absent")
+ }
+ putG3Edges(t, fx.rel, "box", "192.0.2.11", "hapair", "route.example.net", 927, time.Now())
+ fx.srv.edgeFold.mu.Lock()
+ fx.srv.edgeFold.at = time.Now().Add(-edgeFoldTTL - time.Second)
+ fx.srv.edgeFold.mu.Unlock()
+ if out := get(); strings.Contains(out, "192.0.2.11") {
+ t.Fatalf("excluded address retained: %s", out)
+ }
+}
+
+func TestG3RegionalPlacementsExcludeMemberAddresses(t *testing.T) {
+ w := newRegionalWorld(t, "g3-regional")
+ w.putRegionalWorldClaim(t, time.Now())
+ putG3Edges(t, w.fx.rel, "g-bbbbbbbbbbbbbbbbbbbb", "192.0.2.11", "hapair", rdIE, 927, time.Now())
+ putSizeReport(t, w.fx.rel, "g-bbbbbbbbbbbbbbbbbbbb", "", time.Now(), &status.BoxMetrics{Release: rdFloor(), AliasesRead: true})
+ code, _, out := rawReq(t, http.MethodGet, placementsURL(w.fx, "shop", rdHost), w.token, "")
+ if code != 200 || !strings.Contains(out, "203.0.113.10") || strings.Contains(out, "192.0.2.11") {
+ t.Fatalf("regional placements = %d %s", code, out)
+ }
+ // The write door returns the same view after updating the claim.
+ code, out = w.put(t, rdHost, rdBoth())
+ if code != 200 || strings.Contains(out, "192.0.2.11") {
+ t.Fatalf("regional PUT = %d %s", code, out)
+ }
+}
+
+func TestG3SizeDoorPreservesUnknownPoolAndFreshHostEvidence(t *testing.T) {
+ for _, tc := range []struct{ name, evidence, host string }{
+ {"absent", "", ""}, {"null", "null", ""}, {"malformed", `[null]`, ""},
+ {"fresh-host", `["hapair"]`, shopHost},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ fx := newPolicyFx(t, "g3-size-evidence")
+ sizeRecord(t, fx.rel, fx.sqid, "shop", shopHost, "")
+ putG3Edges(t, fx.rel, "fixed", "192.0.2.10", "", "", 8192, time.Now())
+ putG3Edges(t, fx.rel, "other", "192.0.2.11", "hapair", tc.host, 927, time.Now())
+ body, _, err := fx.rel.Get(context.Background(), edgesfile.Key("other"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var fields map[string]json.RawMessage
+ if err := json.Unmarshal(body, &fields); err != nil {
+ t.Fatal(err)
+ }
+ if tc.evidence == "" {
+ delete(fields, "served_pools")
+ } else {
+ fields["served_pools"] = json.RawMessage(tc.evidence)
+ }
+ body, err = json.Marshal(fields)
+ if err != nil {
+ t.Fatal(err)
+ }
+ putFixtureObject(t, fx.rel, edgesfile.Key("other"), body)
+ code, _, out := fx.put(t, "shop", `{"default_size":"small"}`, policyCreate)
+ if code != 409 || !strings.Contains(out, "other (927 MiB)") {
+ t.Fatalf("unknown/host evidence dropped: %d %s", code, out)
+ }
+ })
+ }
+}
diff --git a/internal/console/policysize.go b/internal/console/policysize.go
index 0588345f2..f634ad1c8 100644
--- a/internal/console/policysize.go
+++ b/internal/console/policysize.go
@@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"net/http"
+ "os"
"slices"
"strings"
"time"
@@ -68,10 +69,11 @@ type sizeCommittedBox struct {
// Eligible are the platform boxes of status.LoadBoxesComplete and the
// active roster rows of every fleet the account owns. With records, a
// platform box counts when it is not stale and in the region of one of
-// them (homeRegionIn on both sides), or when its edges file lists one of
-// their hosts, stale or not; a fleet box of the account always counts.
-// With no records (an app default before any instance), every non-stale
-// platform box and every active fleet box of the account.
+// them (homeRegionIn on both sides) and its known served_pools do not
+// exclude that record, or when its edges file lists one of their hosts.
+// Both paths require fresh status. With no records, defaultPool applies
+// across regions; nil means the pool is unknown and excludes no box.
+// Every active fleet box of the account counts.
//
// A box's total is, in order: its edges file's box_mem_total_mib; region
// HA's headroom mem_total_mib (ruling C3); its own status report's
@@ -81,7 +83,7 @@ type sizeCommittedBox struct {
// or a fleet's roster could not be read, or an edges file could not be read
// or parsed. A failed listing of the status reports or of control/edges/ is
// the error, and no boxes.
-func (s *Server) sizeBoxes(ctx context.Context, acct *Account, recs []provision.Record) (boxes []sizeBox, complete bool, err error) {
+func (s *Server) sizeBoxes(ctx context.Context, acct *Account, recs []provision.Record, defaultPool *string) (boxes []sizeBox, complete bool, err error) {
if s.cfg.Releases == nil {
return nil, false, errors.New("no deployment bucket")
}
@@ -99,10 +101,12 @@ func (s *Server) sizeBoxes(ctx context.Context, acct *Account, recs []provision.
for _, f := range snap.Files {
files[f.Box] = files[f.Box].join(f)
}
- hosts, regions := map[string]bool{}, map[string]bool{}
+ hosts := map[string]bool{}
+ regions := map[string][]string{}
for _, r := range recs {
hosts[r.Host] = true
- regions[s.homeRegionIn(r.Region)] = true
+ region := s.homeRegionIn(r.Region)
+ regions[region] = append(regions[region], r.Pool)
}
now := time.Now()
seen := map[string]bool{}
@@ -112,12 +116,21 @@ func (s *Server) sizeBoxes(ctx context.Context, acct *Account, recs []provision.
}
stale := status.BoxStale(b, now, status.SnapshotPeriod)
f := files[b.Label]
+ if stale {
+ continue
+ }
if len(recs) == 0 {
- if stale {
+ if defaultPool != nil && !f.mayServe(*defaultPool) {
+ continue
+ }
+ } else {
+ eligible := f.servesAny(hosts)
+ for _, pool := range regions[s.homeRegionIn(b.Region)] {
+ eligible = eligible || f.mayServe(pool)
+ }
+ if !eligible {
continue
}
- } else if !(!stale && regions[s.homeRegionIn(b.Region)]) && !f.servesAny(hosts) {
- continue
}
seen[b.Label] = true
boxes = append(boxes, sizeBox{Box: b.Label, Region: b.Region, TotalMiB: f.total, report: &reports[i]})
@@ -183,12 +196,14 @@ func (s *Server) sizeBoxes(ctx context.Context, acct *Account, recs []provision.
}
// sizeEdges is what the size check takes from a box's edges files: its
-// total and the hosts it serves. Two files naming one box (a stray copy)
-// join conservatively: an unknown total, or the smaller one.
+// total, served pools and the hosts it serves. Two files naming one box
+// join conservatively: an unknown total, or the smaller one; either file
+// may keep the box eligible for a pool.
type sizeEdges struct {
listed bool
total int64
hosts map[string]bool
+ pools []edgesfile.PoolEvidence
}
func (e sizeEdges) join(f edgesfile.PlacementView) sizeEdges {
@@ -205,6 +220,7 @@ func (e sizeEdges) join(f edgesfile.PlacementView) sizeEdges {
default:
e.total = min(e.total, t)
}
+ e.pools = append(e.pools, f.ServedPools)
e.listed = true
if e.hosts == nil {
e.hosts = map[string]bool{}
@@ -215,6 +231,21 @@ func (e sizeEdges) join(f edgesfile.PlacementView) sizeEdges {
return e
}
+// Unknown or conflicting files keep a box eligible. Only unanimous positive
+// pool exclusions can remove a box from a size check.
+func (e sizeEdges) mayServe(pool string) bool {
+ if !e.listed {
+ return true
+ }
+ for _, evidence := range e.pools {
+ pools, known := evidence.Pools()
+ if !known || slices.Contains(pools, pool) {
+ return true
+ }
+ }
+ return false
+}
+
func (e sizeEdges) servesAny(hosts map[string]bool) bool {
for h := range e.hosts {
if hosts[h] {
@@ -231,8 +262,8 @@ func (e sizeEdges) servesAny(hosts map[string]bool) bool {
// any size: 409 (string 1) when the size's MemoryMax is more than a quarter
// of the smallest known total, naming that box. small and standard are
// never refused for an unknown total or an incomplete read.
-func (s *Server) sizeCapacityCheck(ctx context.Context, acct *Account, recs []provision.Record, size cgroup.Size) ([]sizeBox, *doorRefusal) {
- boxes, complete, err := s.sizeBoxes(ctx, acct, recs)
+func (s *Server) sizeCapacityCheck(ctx context.Context, acct *Account, recs []provision.Record, size cgroup.Size, defaultPool *string) ([]sizeBox, *doorRefusal) {
+ boxes, complete, err := s.sizeBoxes(ctx, acct, recs, defaultPool)
if err != nil {
s.policyLogf("console: size check: %v", err)
complete = false
@@ -329,9 +360,22 @@ func (s *Server) policySizeCheck(ctx context.Context, acct *Account, app string,
if !ok && sizeAboveStandard(c.size) {
return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: sizeUnreadMsg}
}
- // An unread record set is checked against every box (recs nil):
- // more boxes, never fewer.
- boxes, ref := s.sizeCapacityCheck(ctx, acct, recs, c.size)
+ // Only a complete empty record set may use the app's default pool.
+ // Unread records or manifests retain the conservative all-box check.
+ var defaultPool *string
+ if ok && len(recs) == 0 {
+ manifest, err := provision.GetManifest(ctx, s.cfg.Releases, acct.Sqid, app)
+ switch {
+ case err == nil:
+ defaultPool = &manifest.Pool
+ case errors.Is(err, os.ErrNotExist):
+ pool := ""
+ defaultPool = &pool
+ case sizeAboveStandard(c.size):
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: sizeUnreadMsg}
+ }
+ }
+ boxes, ref := s.sizeCapacityCheck(ctx, acct, recs, c.size, defaultPool)
if ref != nil {
return nil, ref
}
diff --git a/internal/console/policysize_test.go b/internal/console/policysize_test.go
index 4f69ac980..ebdd1a60f 100644
--- a/internal/console/policysize_test.go
+++ b/internal/console/policysize_test.go
@@ -87,7 +87,7 @@ func checkSizes(t *testing.T, s *Server, acct *Account, recs []provision.Record,
t.Helper()
out := map[string]*doorRefusal{}
for _, n := range names {
- _, ref := s.sizeCapacityCheck(context.Background(), acct, recs, mustSize(t, n))
+ _, ref := s.sizeCapacityCheck(context.Background(), acct, recs, mustSize(t, n), nil)
out[n] = ref
}
return out
@@ -167,7 +167,7 @@ func TestSizeCapacityRefusesAboveStandardWhenATotalIsMissing(t *testing.T) {
}
putSizeEdges(t, fx.rel, "betty", 0, 16384) // region HA's headroom only
- boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, recs)
+ boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, recs, nil)
if err != nil || !complete {
t.Fatalf("sizeBoxes = %v, %v", complete, err)
}
@@ -245,7 +245,7 @@ func TestSizeCapacityReadsATotalFromTheBoxsStatusReport(t *testing.T) {
t.Fatalf("large with no report from bx-1 = %+v, want 409 naming bx-1", r)
}
putSizeReport(t, fleet, "bx-1", "", time.Now(), fresh)
- boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, recs)
+ boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, recs, nil)
if err != nil || !complete {
t.Fatalf("sizeBoxes = %v, %v", complete, err)
}
@@ -270,7 +270,7 @@ func TestSizeBoxesComeFromTheListingsNotTheEdgesFiles(t *testing.T) {
putSizeEdges(t, fx.rel, "annie", 3884, 0)
putSizeReport(t, fx.rel, "ivy", "ie", now, nil) // another region, serving nothing
putSizeEdges(t, fx.rel, "ivy", 3884, 0)
- putSizeReport(t, fx.rel, "iris", "ie", now.Add(-time.Hour), nil) // stale, but serving the host
+ putSizeReport(t, fx.rel, "iris", "ie", now.Add(-time.Hour), nil) // stale host claims no longer count
putSizeEdges(t, fx.rel, "iris", 7820, 0, shopHost)
putSizeEdges(t, fx.rel, "ghost", 1024, 0, shopHost) // an edges file with no box listing
reg, err := registry.Open(fx.regPath)
@@ -295,18 +295,18 @@ func TestSizeBoxesComeFromTheListingsNotTheEdgesFiles(t *testing.T) {
reg.Close()
recs := []provision.Record{sizeRecord(t, fx.rel, fx.sqid, "shop", shopHost, "")}
- boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, recs)
+ boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, recs, nil)
if err != nil || !complete {
t.Fatalf("sizeBoxes = %v, %v", complete, err)
}
- want := []sizeBox{{Box: "annie", TotalMiB: 3884}, {Box: "bx-1", fleet: "fx"}, {Box: "iris", Region: "ie", TotalMiB: 7820}}
+ want := []sizeBox{{Box: "annie", TotalMiB: 3884}, {Box: "bx-1", fleet: "fx"}}
if !reflect.DeepEqual(noReports(boxes), want) {
t.Fatalf("boxes = %+v, want %+v", boxes, want)
}
// With no records (an app default before any instance), every
// non-stale platform box and the account's active fleet boxes.
- boxes, complete, err = fx.srv.sizeBoxes(context.Background(), acct, nil)
+ boxes, complete, err = fx.srv.sizeBoxes(context.Background(), acct, nil, nil)
if err != nil || !complete {
t.Fatalf("sizeBoxes with no records = %v, %v", complete, err)
}
@@ -324,7 +324,7 @@ func TestSizeCapacityRefusesAboveStandardWhenTheBoxListingIsIncomplete(t *testin
putFixtureObject(t, fx.rel, "status/boxes/zed.json", []byte("{not json"))
recs := []provision.Record{sizeRecord(t, fx.rel, fx.sqid, "shop", shopHost, "")}
- if _, complete, _ := fx.srv.sizeBoxes(context.Background(), acct, recs); complete {
+ if _, complete, _ := fx.srv.sizeBoxes(context.Background(), acct, recs, nil); complete {
t.Fatal("sizeBoxes says complete with an unreadable status report")
}
got := checkSizes(t, fx.srv, acct, recs, "large", "standard")
@@ -348,7 +348,7 @@ func TestSizeCommittedReportsEachBox(t *testing.T) {
putSizeReport(t, release.NewPrefixStore(fx.rel, "fleets/fx/"), "bx-1", "", time.Now(),
&status.BoxMetrics{SizeCommittedMiB: &fc, MemTotalBytes: &ft, MemAvailBytes: &fa})
- boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, nil)
+ boxes, complete, err := fx.srv.sizeBoxes(context.Background(), acct, nil, nil)
if err != nil || !complete {
t.Fatalf("sizeBoxes = %v, %v", complete, err)
}
diff --git a/internal/console/server.go b/internal/console/server.go
index b4c3fdb82..0fda8f3ac 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1636,7 +1636,7 @@ func (s *Server) dnsTargets(ctx context.Context) DNSTargets {
// edgeIPs is the DNS address union. Configured ingress is deployment-wide:
// it suppresses every box file, including non-HA regions. Agents must already
// recognize this public set through PLATFORM_EDGE_IPS before it is enabled.
-// Unset ingress preserves the legacy fold and its shared cache.
+// Unset ingress folds only stable DNS targets, using the shared cache.
func (s *Server) edgeIPs(ctx context.Context) []string {
if len(s.cfg.RegionIngress) > 0 {
var out []string
@@ -1659,10 +1659,10 @@ func (s *Server) edgeIPs(ctx context.Context) []string {
// foldedEdgeIPs answers the cached fold, refreshing it when it has aged past
// edgeFoldTTL.
//
-// A refresh that comes back with NOTHING leaves the previous answer standing:
-// an empty fold is a bucket that could not be read this minute far more often
-// than it is a deployment that lost every edge, and emptying the set would
-// silently narrow the guidance every member is shown. The timestamp still
+// A failed refresh (nil) leaves the previous answer standing:
+// a failed read cannot establish that the deployment lost every edge.
+// A complete empty fold clears the cache, including addresses that are now
+// excluded by pool or membership evidence. The timestamp still
// moves, so a persistent outage costs one bounded attempt per TTL rather than
// one per request.
//
@@ -1686,7 +1686,7 @@ func (s *Server) foldedEdgeIPs(ctx context.Context) []string {
defer cancel()
ips := fold(fctx)
c.at = time.Now()
- if len(ips) > 0 {
+ if ips != nil {
c.ips = ips
}
return c.ips
@@ -1695,21 +1695,32 @@ func (s *Server) foldedEdgeIPs(ctx context.Context) []string {
// realFoldEdgeIPs folds the deployment bucket's edges files. env is nil here,
// not cfg.EdgeIPs: edgeIPs above does the union, so the configured list is
// added exactly once and the cache holds only what was actually read from the
-// bucket — which is what lets an empty fold be recognised as a failed read.
+// bucket. A nil result means the fold could not establish an address set.
// Sorted so a listing's guidance sentence does not reshuffle between calls on
// the store's arbitrary iteration order.
func (s *Server) realFoldEdgeIPs(ctx context.Context) []string {
if s.cfg.Releases == nil {
return nil
}
- // The box reports and the edges files are read concurrently
- // (readConcurrently). The dry pass's body is a live box report and a
- // versioned edges file for one made-up box at once, which EdgeIPs
- // accepts for either without logging.
+ // Keep the existing concurrent-read budget for reports and edges files.
now := time.Now()
dry := []byte(`{"v":1,"box":"-","label":"-","generated_at":"` + now.UTC().Format(time.RFC3339) + `"}`)
ips := readConcurrently(ctx, s.cfg.Releases, dry, boxReportKeyLimit, func(st release.Store) []string {
- return edgesfile.EdgeIPs(ctx, st, nil, now)
+ snap, err := readLiveEdgesSnapshot(ctx, st, now)
+ if err != nil {
+ return nil
+ }
+ snap = s.dnsAddressSnapshot(snap)
+ out := make([]string, 0)
+ for _, f := range snap.Files {
+ if f.Fresh && f.EIP != "" && !slices.Contains(out, f.EIP) {
+ out = append(out, f.EIP)
+ }
+ }
+ if len(out) == 0 && !snap.EvidenceComplete() {
+ return nil
+ }
+ return out
})
slices.Sort(ips)
return ips
diff --git a/internal/host/aliasesread_e2e_test.go b/internal/host/aliasesread_e2e_test.go
index bcc2787bd..31192950c 100644
--- a/internal/host/aliasesread_e2e_test.go
+++ b/internal/host/aliasesread_e2e_test.go
@@ -149,7 +149,7 @@ func (w *arWorld) box(name, placement, eip, serves string) *arBox {
w.t.Fatal(err)
}
var last []byte
- if err := edgesFileWrite(context.Background(), w.s, reg, edgesFile{Box: name, Region: "eu-west-1", Placement: placement}, eip, &last, false); err != nil {
+ if err := edgesFileWrite(context.Background(), w.s, reg, edgesFile{Box: name, Region: "eu-west-1", Placement: placement, ServesSharedPool: true}, eip, &last, false); err != nil {
w.t.Fatal(err)
}
return b
@@ -300,7 +300,7 @@ func TestFailedAliasReadIsIncompleteEvidence(t *testing.T) {
}
// Republished with the row in place: not pointing, so withheld.
var last []byte
- if err := edgesFileWrite(context.Background(), w.s, w.betty.reg, edgesFile{Box: "betty", Region: "eu-west-1", Placement: "uk"}, w.betty.eip, &last, false); err != nil {
+ if err := edgesFileWrite(context.Background(), w.s, w.betty.reg, edgesFile{Box: "betty", Region: "eu-west-1", Placement: "uk", ServesSharedPool: true}, w.betty.eip, &last, false); err != nil {
t.Fatal(err)
}
if raw, _, err := w.s.Get(context.Background(), edgesFileKey("betty")); err != nil || strings.Contains(string(raw), `"`+arHost+`"`) {
diff --git a/internal/host/edgesfile_group_guard_test.go b/internal/host/edgesfile_group_guard_test.go
new file mode 100644
index 000000000..42fb37da6
--- /dev/null
+++ b/internal/host/edgesfile_group_guard_test.go
@@ -0,0 +1,66 @@
+package host
+
+import (
+ "context"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/edgesfile"
+ "github.com/carlosframework/platform/internal/hostenv"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// The group boot constructor admits named pools only. Steering has no
+// identity snapshot, so that constructor and the publisher must agree that
+// members never advertise shared-pool eligibility.
+func TestG3GroupWriterPublishesNoSharedPool(t *testing.T) {
+ for _, pools := range []string{"hapair", "hapair,cohort1"} {
+ t.Run(pools, func(t *testing.T) {
+ placement := ""
+ cfg := hostenv.GroupConfig{V: 1, Account: "123456789012", AWSRegion: "eu-west-1", DeploymentAWSRegion: "eu-west-1", Region: "ie", Deployment: "dev", Bucket: "deploy", DataBucket: "data", Group: "dev-ie", Hook: "carlos-initial-launch", Placement: &placement, Pools: strings.Split(pools, ","), KnownReaders: []string{"fixed"}, Release: "v1.2.3", Floor: "absent-expected"}
+ regional := map[string]string{}
+ for _, key := range hostenv.Required {
+ regional[key] = "value"
+ }
+ for key, value := range map[string]string{"CARLOS_REGION": "", "CARLOS_REGION_HA": "true", "CARLOS_GROUP_ADMISSION": "1", "CARLOS_CHANGE_INDEX": "read", "CARLOS_POOLS": pools, "AWS_REGION": "eu-west-1", "CARLOS_DEPLOYMENT_BUCKET": "deploy", "CARLOS_HIBERNATE_REGION": "eu-west-1", "CARLOS_HIBERNATE_BUCKET": "data"} {
+ regional[key] = value
+ }
+ env, err := hostenv.AssembleGroup(nil, regional, cfg, "group-queue")
+ if err != nil {
+ t.Fatal(err)
+ }
+ getenv := func(k string) string { return env[k] }
+ if !groupReferenced(getenv) {
+ t.Fatal("fixture is not a group member")
+ }
+ shared, inbound, named := edgesFileEligibility(getenv)
+ ident := edgesFile{Box: "g-bbbbbbbbbbbbbbbbbbbb", BoxID: "g-bbbbbbbbbbbbbbbbbbbb", ServesSharedPool: shared, AcceptsInbound: inbound, NamedPools: named, ServedPools: edgesFileServedPools(provisionTickConfig(getenv))}
+ store, reg := release.NewDirStore(t.TempDir()), edgesTestRegistry(t)
+ var last []byte
+ if err := edgesFileWriteClaims(context.Background(), store, reg, ident, "192.0.2.11", &last, true, nil, false, nil, nil); err != nil {
+ t.Fatal(err)
+ }
+ snap, err := edgesfile.ReadSnapshot(context.Background(), store)
+ if err != nil || len(snap.Files) != 1 {
+ t.Fatalf("snapshot: %+v %v", snap, err)
+ }
+ f := snap.Files[0]
+ if f.AcceptsInbound == nil || !*f.AcceptsInbound {
+ t.Fatal("member did not accept inbound")
+ }
+ if f.ServesSharedPool == nil || *f.ServesSharedPool || f.ServedPools.Serves("") || !f.ServedPools.Serves("hapair") {
+ t.Fatalf("group advertised shared-pool eligibility: %+v", f)
+ }
+ })
+ }
+}
+
+func TestG3GroupBootRefusesSharedPool(t *testing.T) {
+ for _, pools := range [][]string{nil, {""}, {"@shared"}, {"hapair", "@shared"}} {
+ placement := ""
+ cfg := hostenv.GroupConfig{V: 1, Account: "123456789012", AWSRegion: "eu-west-1", DeploymentAWSRegion: "eu-west-1", Region: "ie", Deployment: "dev", Bucket: "deploy", DataBucket: "data", Group: "dev-ie", Hook: "carlos-initial-launch", Placement: &placement, Pools: pools, KnownReaders: []string{"fixed"}, Release: "v1.2.3", Floor: "absent-expected"}
+ if _, err := hostenv.AssembleGroup(nil, nil, cfg, "group-queue"); err != hostenv.ErrGroupConfig {
+ t.Fatalf("shared pools %q: %v", pools, err)
+ }
+ }
+}