carlos / platform Public

ha: gate new creates on shared capacity evidence: review fixes r1

claude agent, operated by paul@keymail.dev 6068881c539fdfa382e781e49b292a9a5d9bbb9a parent b3aeab3
42 files changed, +448 −298
  • internal/console/apidomainbuy.go +1 −1
  • internal/console/apidomains.go +6 −6
  • internal/console/apiinstanceimport.go +7 −7
  • internal/console/apiinstances.go +15 −15
  • internal/console/apiinstanceseed.go +13 −13
  • internal/console/apiplacements.go +20 −20
  • internal/console/apipolicy.go +9 −9
  • internal/console/apiship_rootfs.go +6 −6
  • internal/console/apisidecars.go +2 −2
  • internal/console/appdomainbuy.go +1 −1
  • internal/console/appregionset.go +18 −18
  • internal/console/claim_first_route.go +1 −1
  • internal/console/claim_response.go +3 −3
  • internal/console/createleftovers.go +6 −6
  • internal/console/demo_data.go +1 −1
  • internal/console/demo_domains.go +3 −3
  • internal/console/domainattach.go +61 −60
  • internal/console/domainbuy.go +16 −10
  • internal/console/domainbuy_capacity_test.go +94 −0
  • internal/console/domainbuy_copy.go +4 −4
  • internal/console/domaincatchall.go +10 −10
  • internal/console/egressfleet.go +6 −6
  • internal/console/fleetfloor.go +3 −3
  • internal/console/hacreate.go +1 −1
  • internal/console/hacreate_test.go +1 −1
  • internal/console/hacreatecapacity_test.go +45 −0
  • internal/console/hostsused.go +19 −19
  • internal/console/lifetimes.go +6 −6
  • internal/console/lifetimes_floor.go +4 −4
  • internal/console/lifetimes_retire.go +3 −3
  • internal/console/nocapacity.go +8 −4
  • internal/console/nocapacity_test.go +1 −1
  • internal/console/plancaps.go +2 −2
  • internal/console/policylease.go +7 −7
  • internal/console/policysize.go +4 −4
  • internal/console/regionclaim.go +3 −3
  • internal/console/rootfs.go +16 −16
  • internal/console/seedfloor.go +8 −8
  • internal/console/seedscratch.go +4 −4
  • internal/console/teamcreds.go +2 −2
  • internal/console/teamenv.go +3 −3
  • internal/console/teamfloor.go +5 −5

CI cancelled — superseded by a newer push — run details

Intent

Human

<task-notification> <task-id>bvj9xyxka</task-id> <tool-use-id>toolu_01GPjpLucanG7jsGob1hErt3</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/de069047-3c6a-40e7-ae66-85194f066976/tasks/bvj9xyxka.output</output-file> <status>completed</status> <summary>Background command "Wait for T3 implementer" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a16d2ec0115e19d56</task-id> <tool-use-id>toolu_01JQdNUBntnSqwk7dKWnCoTC</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/de069047-3c6a-40e7-ae66-85194f066976/tasks/a16d2ec0115e19d56.output</output-file> <status>completed</status> <summary>Agent "Review T3 (spec + quality)" 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>**T3 review: Region HA P2b-1 create-capacity gate (1c509c89..b3aeab32)** **Verdict:** no P1, one P2, six P3. Spec ✅. Code quality: Approved once the P2 is fixed. No tests re-run; one doubt (the lifetimes reattach read) was settled by reading code. **Spec compliance** - **I1:** the helper is called from exactly three places: `apiinstances.go:2340`, `apisidecars.go:422` and `domainattach.go:234`. The metric uses `HACapacity()` directly. Wake, enable, restart, deploy and retry are not touched, and the alias branch (`domainattach.go:174`) returns before the gate. - **I5, instance:** auth, ownership, shape, the binding-refusal read, F1/F5 (leftover rail), the plan cap and the permanent HA import refusal (`seeded &amp;&amp; haRegion`) all come before capacity. Capacity comes before `createFrom`/`createImport` dispatch, the fleet label mark, `beginClaimCreate`, environment binding, store provisioning, lifetimes and the record write. Nothing between line 1524 and the gate writes; I scanned for Put, Exec, Mark, Register, audit and serial. - The early roomIn and PlaceableBoxes checks are skipped for active HA regions, so only one policy is live. - The armed-region 400 is deferred to after capacity (`checkPlacement`). Non-HA regions follow main's order unchanged. - **I5, sidecar:** the effective region and `m.Pool` are checked after the pause, cap and leftover rails, and before either write arm. HA stamping is unchanged. - **I5, first domain:** the gate sits after `heldElsewhere` and before the claims/lifetimes/plain split, so it also precedes pending-proof claim writes. The reattach read is judged under lifetimes: `recordCtx` adds the judge whenever `lifetimesUnit` is true, so a stale body still requires capacity. - **Responses:** complete zero goes through `noRoom` with C01 and the existing throttle. Unknown never pages and never publishes a zero. C04 and C10 match `copy-approved.md` exactly. Browser responses get Retry-After through `renderDoorRefusal`. - **I8:** the helper runs only after the auth and 404 paths. C10 names only the caller's own pool and region. - **Census re-pin is legitimate, not a weakening:** the new `os.Open` lines are the real T1 sites (`hacapacity_observe.go:102,188`). The CloudWatch line is T2's renamed constructor with `NopRetryer`. Nothing is removed. One thing to note: the census must have been red at the T1 and T2 heads. **Tests** - They assert status, the exact body and `Retry-After`, plus: - zero PUT/DELETE through the store wrappers and bucket-state equality; - SQLite triggers on the console tables and every registry table; - the private-storage adapter seam and the claims recorder. - They cover plain, lifetimes and claims modes, and instance, binary, address, sidecar, API and browser doors. - Named pools (instance and sidecar, hapair and cohort1) use T0's golden file: new publisher, old, null, mixed-positive, mixed-missing (gives C10), absent-membership (gives zero), `accepts_inbound=false` (gives zero) and malformed. - The shared-observation test makes no observation reads during the requests. The throttle test covers an in-flight send, send-failure release and a restart. **Findings** - **P2 – a create door that is gated but never tested** (I5 witness gap). `domainbuy.go:579`: the domain-purchase reconciler calls `attachDomain` for the apex in the background, so it now goes through the gate. That is probably correct. But on unknown or zero evidence the refusal text (C04 or C01) is saved as `p.Reason`, each pass increments `Attempts`, and at 10 attempts it fires `purchaseAlert` with the capacity text. A zero also sends a capacity page from a background pass. Neither the tests nor the report mention it. Add one witness (purchase reconcile under zero and unknown: no record or claim write, reason and attempt behaviour pinned), or record a decision that it should be exempt. - **P3 – extra reads not in the I3 budget.** These add one GET per HA create and are not in the I3 "0G" row; the report claims zero incremental reads: - the duplicate pre-reads at `apiinstances.go:2281` and `apisidecars.go:391`; - the first-route record read at `domainattach.go:229`. The shared-observation test counts only LISTs on the evidence prefixes, so it would not catch them. They are needed for duplicate-before-capacity ordering, so the fix is to disclose them in the card, not remove them. - **P3 – Retry-After matched by message text.** `nocapacity.go:144-145` decides on Retry-After by matching the start of the message ("Capacity evidence for " / "Capacity for pool "). A copy edit would silently drop the header. A typed marker on `doorRefusal` would be safer. - **P3 – incomplete region list in a 400.** `apiinstances.go:~1886`: for an app-derived HA region, `cands` is nil, so the region-not-allowed 400's `instanceChoices(..., nil, ...)` can leave eligible coded regions out of its list. The status code and ordering are correct. - **P3 – S3 reads under the account lock.** For HA regions, `checkPlacement` (the `placementsIn` LIST plus `liveEdges`) now runs while `lockAccount` is held. That adds latency to same-account creates. - **P3 – reattach exemption tested in plain mode only.** `TestHACreateCapacityReattachExistingFirstRoute` has no claims-mode or lifetimes-mode case. - **P3 – auth 404 not compared byte for byte.** The "auth" precedence case checks the status and the absence of capacity text, but does not compare the 404 body to a non-HA baseline. **⚠️ Items** - In claims mode, the regional-claim and DNS-proof refusals (`claim_first_route.go:21-29`) now come after capacity, so an unproven attach during a zero gets 503 instead of 409. The design's "before the branch at :227" rule requires this, but it puts a permanent refusal behind capacity. - The existing-work witness's "enable" door is `PUT /instances-manifest` (enabling instances on the app), not a record-level enable. No separate record-enable route exists, so this is acceptable. - Malformed `named_pools` returns C04, not C10. That follows T1's decision API and is consistent with the design's "missing input" wording. The design, brief and report are in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-p2b-build/.superpowers/sdd/2026-11-04-region-ha-p2b-console/`. The new tests are in `internal/console/hacreatecapacity_test.go`.</result> <usage><subagent_tokens>145718</subagent_tokens><tool_uses>39</tool_uses><duration_ms>404911</duration_ms></usage> </task-notification>

Attributed to this commit: 17.5 g CO₂e (2,178,517 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p2b-build, 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/internal/console/apidomainbuy.go b/internal/console/apidomainbuy.go
index 231e7128e..99435a977 100644
--- a/internal/console/apidomainbuy.go
+++ b/internal/console/apidomainbuy.go
@@ -37,7 +37,7 @@ func (s *Server) domainBuyAPIGate(w http.ResponseWriter, r *http.Request) (strin
func (s *Server) checkDomainBuy(ctx context.Context, acct *Account, name, country string) (domainreg.Quote, *doorRefusal) {
if country != "" && (len(country) != 2 || country[0] < 'A' || country[0] > 'Z' || country[1] < 'A' || country[1] > 'Z') {
- return domainreg.Quote{}, &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["contactError"]}
+ return domainreg.Quote{}, &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]}
}
if country == "" {
c, _, err := s.store.DomainContact(acct.ID)
diff --git a/internal/console/apidomains.go b/internal/console/apidomains.go
index faf3f3f6e..e127ee3d3 100644
--- a/internal/console/apidomains.go
+++ b/internal/console/apidomains.go
@@ -741,7 +741,7 @@ func (s *Server) setDomainCapabilities(w http.ResponseWriter, r *http.Request, c
if catchall && !cur.Catchall {
if ref := s.regionalDescendantRefusal(ctx, host); ref != nil {
if ref.Status == http.StatusConflict {
- ref = &doorRefusal{http.StatusConflict, catchallOverRegionalMsg(host)}
+ ref = &doorRefusal{Status: http.StatusConflict, Msg: catchallOverRegionalMsg(host)}
}
jsonError(w, ref.Status, ref.Msg)
return false
@@ -855,7 +855,7 @@ func (s *Server) wildcardEnablingRefusal(ctx context.Context, p Principal, host
// wildcards spec's ACME story (§4): this deployment's own zone
// issues the wildcard cert, so it must control the challenge record.
if s.delegationZone == "" {
- return &doorRefusal{http.StatusUnprocessableEntity, "deployment has no delegation zone configured"}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: "deployment has no delegation zone configured"}
}
// PEEKED before the DNS round trip (C33 review): once a principal
// has already tripped wildFail, running the lookup again buys the
@@ -865,7 +865,7 @@ func (s *Server) wildcardEnablingRefusal(ctx context.Context, p Principal, host
// CONSUMED (below) put there — so this can never turn away a
// legitimate, exempt caller.
if s.wildFailTripped(p, time.Now()) {
- return &doorRefusal{http.StatusTooManyRequests, wildFailMsg}
+ return &doorRefusal{Status: http.StatusTooManyRequests, Msg: wildFailMsg}
}
if !s.delegationCNAMEDelegated(ctx, host) {
// CONSUMED only here, on an ACTUAL failure (spec §4a). A
@@ -876,10 +876,10 @@ func (s *Server) wildcardEnablingRefusal(ctx context.Context, p Principal, host
// FAILURES rather than on attempts — a caller whose CNAME is
// correct never meets it at all.
if !s.allowWildFail(p, time.Now()) {
- return &doorRefusal{http.StatusTooManyRequests, wildFailMsg}
+ return &doorRefusal{Status: http.StatusTooManyRequests, Msg: wildFailMsg}
}
- return &doorRefusal{http.StatusUnprocessableEntity,
- "create CNAME _acme-challenge." + host + " -> _acme-challenge." + host + "." + s.delegationZone + ", then retry"}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "create CNAME _acme-challenge." + host + " -> _acme-challenge." + host + "." + s.delegationZone + ", then retry"}
}
return nil
}
diff --git a/internal/console/apiinstanceimport.go b/internal/console/apiinstanceimport.go
index 1c91e8c84..c9d45835e 100644
--- a/internal/console/apiinstanceimport.go
+++ b/internal/console/apiinstanceimport.go
@@ -62,7 +62,7 @@ var (
// one seed door: "from" and "import" together are refused.
func seedOneDoorRefusal(from, imp bool) *doorRefusal {
if from && imp {
- return &doorRefusal{http.StatusBadRequest, "a create takes from or import, not both."}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: "a create takes from or import, not both."}
}
return nil
}
@@ -73,13 +73,13 @@ func seedOneDoorRefusal(from, imp bool) *doorRefusal {
func importShapeRefusal(imp seedImportReq) *doorRefusal {
switch {
case imp.Bytes <= 0:
- return &doorRefusal{http.StatusBadRequest, importSizeRule}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: importSizeRule}
case imp.Bytes > seedMaxBytes:
- return &doorRefusal{http.StatusRequestEntityTooLarge, importSizeRule}
+ return &doorRefusal{Status: http.StatusRequestEntityTooLarge, Msg: importSizeRule}
case !sha256Hex.MatchString(imp.SHA256):
- return &doorRefusal{http.StatusBadRequest, "sha256 must be 64 lowercase hex characters"}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: "sha256 must be 64 lowercase hex characters"}
case !validReplaces(imp.Replaces):
- return &doorRefusal{http.StatusBadRequest, "replaces must name the address the import takes over, as host:port"}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: "replaces must name the address the import takes over, as host:port"}
}
return nil
}
@@ -489,7 +489,7 @@ func awaitingUpload(rec *provision.Record, id string) bool {
// notAnImportRefusal is SD-N59.
func notAnImportRefusal(host string) *doorRefusal {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s is not an import.", host)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s is not an import.", host)}
}
// staleUploadRefusal is the upload's answer to a record that no longer
@@ -502,7 +502,7 @@ func staleUploadRefusal(host string, rec *provision.Record, id string) *doorRefu
case !rec.Seed.Import():
return notAnImportRefusal(host)
}
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s is %s. It takes an upload only while it waits for one.", host, rec.Seed.State)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s is %s. It takes an upload only while it waits for one.", host, rec.Seed.State)}
}
// spoolImport reads the body into spool, never more than the declared
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index 117556a22..8df6cef9b 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -1492,15 +1492,15 @@ func checkReplicaCreate(req replicaFields, rec *provision.Record) *doorRefusal {
// live. (The armed-placement gate below refuses one that names no real
// box; this refuses one that names nothing at all.)
if req.Role != "" && rec.Region == "" {
- return &doorRefusal{http.StatusBadRequest,
- "role replica needs a placement — pass the placement code the replica lives in as the create's region"}
+ return &doorRefusal{Status: http.StatusBadRequest,
+ Msg: "role replica needs a placement — pass the placement code the replica lives in as the create's region"}
}
// A replica does not carry a replica set of its own: the set is the
// HOME's opt-in naming where its replicas live, and a replica of a
// replica is not a shape the platform carries.
if req.Role != "" && len(req.Replicas) > 0 {
- return &doorRefusal{http.StatusBadRequest,
- "role replica with replicas: the placement set is the HOME record's opt-in — a replica does not carry one"}
+ return &doorRefusal{Status: http.StatusBadRequest,
+ Msg: "role replica with replicas: the placement set is the HOME record's opt-in — a replica does not carry one"}
}
// The home's own placement set is canonicalized (sorted, deduped,
// ValidRegion-checked) in place, so the wire column never carries a
@@ -1509,7 +1509,7 @@ func checkReplicaCreate(req replicaFields, rec *provision.Record) *doorRefusal {
if len(req.Replicas) > 0 {
norm, err := provision.ValidReplicas(req.Replicas)
if err != nil {
- return &doorRefusal{http.StatusBadRequest, err.Error()}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: err.Error()}
}
rec.Replicas = norm
}
@@ -2306,8 +2306,8 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request)
return err == nil, err
},
// The same two answers the CreateRecord call below gives.
- duplicate: doorRefusal{http.StatusConflict, "instance " + host + " already exists"},
- readFailed: doorRefusal{http.StatusBadGateway, "could not create the instance — try again"},
+ duplicate: doorRefusal{Status: http.StatusConflict, Msg: "instance " + host + " already exists"},
+ readFailed: doorRefusal{Status: http.StatusBadGateway, Msg: "could not create the instance — try again"},
taken: host + " still holds data from a deleted instance. Choose another address, or ask an operator to purge it.",
unsure: "could not check whether " + host + " is free. Try again.",
}); ref != nil {
@@ -2603,8 +2603,8 @@ func (s *Server) instanceChannel(ctx context.Context, sqid, app string, m *provi
recs, _, err := s.listRecords(ctx, sqid, app, instanceListMax)
if err != nil {
log.Printf("console: api instances create %s/%s: list siblings: %v", sqid, app, err)
- return "", &doorRefusal{http.StatusBadGateway,
- "could not read this app's instances — try again, or pass -channel"}
+ return "", &doorRefusal{Status: http.StatusBadGateway,
+ Msg: "could not read this app's instances — try again, or pass -channel"}
}
var found []string
for _, rec := range recs {
@@ -2617,8 +2617,8 @@ func (s *Server) instanceChannel(ctx context.Context, sqid, app string, m *provi
}
slices.Sort(found)
if len(found) > 1 {
- return "", &doorRefusal{http.StatusUnprocessableEntity,
- "this app's instances follow several channels (" + strings.Join(found, ", ") +
+ return "", &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "this app's instances follow several channels (" + strings.Join(found, ", ") +
") — pass -channel to say which one this instance follows"}
}
if len(found) == 1 {
@@ -2627,8 +2627,8 @@ func (s *Server) instanceChannel(ctx context.Context, sqid, app string, m *provi
p, err := release.GetPipeline(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app)
if err != nil {
log.Printf("console: api instances create %s/%s: pipeline read: %v", sqid, app, err)
- return "", &doorRefusal{http.StatusBadGateway,
- "could not read this app's pipeline — try again, or pass -channel"}
+ return "", &doorRefusal{Status: http.StatusBadGateway,
+ Msg: "could not read this app's pipeline — try again, or pass -channel"}
}
if p != nil {
return p.Entry(), nil
@@ -2669,8 +2669,8 @@ func staticHeadRefusal(head *channelHead, app, channel, kind, host string) *door
if head == nil || head.Manifest.Kind != "static" {
return nil
}
- return &doorRefusal{http.StatusUnprocessableEntity,
- "channel " + channel + " serves a static release (" + head.Version + "), and an instance runs a process — " +
+ return &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "channel " + channel + " serves a static release (" + head.Version + "), and an instance runs a process — " +
"a static site is served straight off the channel pointer, so it needs no instance at all. " +
"Pass --kind static, or let one command do the whole thing: carlos deploy --app " + app +
" --kind static --host " + host + " <site-dir>"}
diff --git a/internal/console/apiinstanceseed.go b/internal/console/apiinstanceseed.go
index 3596d7a09..4ca817044 100644
--- a/internal/console/apiinstanceseed.go
+++ b/internal/console/apiinstanceseed.go
@@ -99,13 +99,13 @@ func seedCommonRefusal(kind string, addrs []string, role string, replicas []stri
// seedOrdinaryRefusal is SD-N36, the shape rule's answer.
func seedOrdinaryRefusal() *doorRefusal {
- return &doorRefusal{http.StatusBadRequest, "a seeded instance is an ordinary instance. Drop --kind, --addr and --role."}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: "a seeded instance is an ordinary instance. Drop --kind, --addr and --role."}
}
// seedNoDataRefusal is both doors' answer on a console with no data bucket
// for seeds.
func seedNoDataRefusal() *doorRefusal {
- return &doorRefusal{http.StatusServiceUnavailable, "this console has no data bucket set up, so it cannot create a seeded instance."}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: "this console has no data bucket set up, so it cannot create a seeded instance."}
}
// seedPlacementRefusal is both seed doors' placement rule: the platform
@@ -115,7 +115,7 @@ func seedPlacementRefusal(c seedCreate) *doorRefusal {
return demoDataRefusal()
}
if c.placed != "" || c.m.Pool != "" {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s places its instances in a pool or on a fleet, so it cannot take a seeded instance.", c.app)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s places its instances in a pool or on a fleet, so it cannot take a seeded instance.", c.app)}
}
return nil
}
@@ -136,9 +136,9 @@ func (s *Server) refuseSeededEnvironment(w http.ResponseWriter) {
// review F6), the sentence that says so and what to do.
func seedStoreTakenRefusal(env, app string, store *objstore.Record) *doorRefusal {
if bucket := storeBucketName(store); bucket != "" {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("environment %s already has a store (%s). A seeded instance needs a new, empty one.", env, bucket)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("environment %s already has a store (%s). A seeded instance needs a new, empty one.", env, bucket)}
}
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("environment %s is already used by another instance of %s. A seeded instance gets a new environment named after its host, so choose another host.", env, app)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("environment %s is already used by another instance of %s. A seeded instance gets a new environment named after its host, so choose another host.", env, app)}
}
// seedSiblingApexReason is the sentence both seed doors speak when an app
@@ -188,7 +188,7 @@ func (s *Server) seedStoreRefusal(ctx context.Context, c seedCreate, seedID, fai
rec, _, err := objstore.GetIn(ctx, s.cfg.Releases, c.acct.Sqid, c.app, c.rec.Environment)
if err != nil {
log.Printf("console: seed store check %s/%s/%s: %v", c.acct.Sqid, c.app, c.rec.Environment, err)
- return &doorRefusal{http.StatusBadGateway, failed}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: failed}
}
if !seedOwnsStore(rec, seedID) {
return seedStoreTakenRefusal(c.rec.Environment, c.app, rec)
@@ -196,7 +196,7 @@ func (s *Server) seedStoreRefusal(ctx context.Context, c seedCreate, seedID, fai
user, err := s.seedEnvironmentUser(ctx, c.acct.Sqid, c.app, c.rec.Environment, seedID)
if err != nil {
log.Printf("console: seed store check %s/%s/%s: who names the environment: %v", c.acct.Sqid, c.app, c.rec.Environment, err)
- return &doorRefusal{http.StatusBadGateway, failed}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: failed}
}
if user != "" {
log.Printf("console: seed store check %s/%s/%s: instance %s already names the environment", c.acct.Sqid, c.app, c.rec.Environment, user)
@@ -566,22 +566,22 @@ func (s *Server) fromSourceRefusal(src dbSource, source, app string, err error)
case err == nil:
return nil
case errors.Is(err, os.ErrNotExist), errors.Is(err, ErrBadHost):
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("no instance %s in %s. A copy can only come from an instance of the same app in the same account.", source, app)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("no instance %s in %s. A copy can only come from an instance of the same app in the same account.", source, app)}
case errors.Is(err, errSourceClass):
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s is not an instance the platform keeps a replica of, so it cannot be copied.", source)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s is not an instance the platform keeps a replica of, so it cannot be copied.", source)}
case errors.Is(err, ErrPooled):
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s runs in the pool %s, so the platform keeps no replica of it to copy.", source, src.rec.Pool)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s runs in the pool %s, so the platform keeps no replica of it to copy.", source, src.rec.Pool)}
case errors.Is(err, ErrResidency):
if fleet, ok := registry.FleetPlacement(src.rec.Region); ok {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s runs on your fleet %s, so the platform keeps no replica of it to copy.", source, fleet)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s runs on your fleet %s, so the platform keeps no replica of it to copy.", source, fleet)}
}
- return &doorRefusal{http.StatusConflict, s.dbResidencyRefusal(src.rec)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: s.dbResidencyRefusal(src.rec)}
case errors.Is(err, errSourceClaim):
// Unreachable while seedRegionReady refuses a claim console first.
return seedClaimConsoleRefusal()
}
log.Printf("console: from %s: resolve: %v", source, err)
- return &doorRefusal{http.StatusBadGateway, fmt.Sprintf("could not copy %s. Nothing was created. Try again.", source)}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: fmt.Sprintf("could not copy %s. Nothing was created. Try again.", source)}
}
// uploadSnapshot hashes path and writes it to key with one create-only
diff --git a/internal/console/apiplacements.go b/internal/console/apiplacements.go
index 0548d0413..993a68e34 100644
--- a/internal/console/apiplacements.go
+++ b/internal/console/apiplacements.go
@@ -697,7 +697,7 @@ func onceProver(prove func() bool) func() bool {
// says nothing of other apps' and accounts' instances. Sorted by nothing: body order is kept.
func (s *Server) placementsBindings(ctx context.Context, acct *Account, app, host string, in []placementIn) ([]domains.Placement, *doorRefusal) {
if len(in) == 0 || len(in) > domains.MaxPlacements {
- return nil, &doorRefusal{http.StatusBadRequest, placementsCountMsg}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: placementsCountMsg}
}
set := make([]domains.Placement, 0, len(in))
named := make([]string, 0, len(in)) // each region as the member named it
@@ -705,19 +705,19 @@ func (s *Server) placementsBindings(ctx context.Context, acct *Account, app, hos
for _, b := range in {
given := strings.TrimSpace(b.Region)
if given == "" {
- return nil, &doorRefusal{http.StatusBadRequest, placementsNotInstanceMsg(b.Host, given)}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: placementsNotInstanceMsg(b.Host, given)}
}
code := s.homeRegionIn(strings.ToLower(given))
if regions[code] {
- return nil, &doorRefusal{http.StatusBadRequest, placementsRegionTwiceMsg(given)}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: placementsRegionTwiceMsg(given)}
}
regions[code] = true
host, ok := domains.NormalizeAliasHost(strings.TrimSpace(b.Host))
if !ok || strings.HasSuffix(host, provision.SidecarSuffix) {
- return nil, &doorRefusal{http.StatusBadRequest, placementsNotInstanceMsg(b.Host, given)}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: placementsNotInstanceMsg(b.Host, given)}
}
if hosts[host] {
- return nil, &doorRefusal{http.StatusBadRequest, placementsHostTwiceMsg(host)}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: placementsHostTwiceMsg(host)}
}
hosts[host] = true
set = append(set, domains.Placement{Region: code, Host: host})
@@ -726,7 +726,7 @@ func (s *Server) placementsBindings(ctx context.Context, acct *Account, app, hos
recs, _, err := s.listRecords(ctx, acct.Sqid, app, instanceListMax)
if err != nil {
log.Printf("console: api domain placements put %s/%s: list records: %v", acct.Sqid, app, err)
- return nil, &doorRefusal{http.StatusBadGateway, "could not read this app's instances"}
+ return nil, &doorRefusal{Status: http.StatusBadGateway, Msg: "could not read this app's instances"}
}
byHost := make(map[string]provision.Record, len(recs))
for _, rec := range recs {
@@ -739,14 +739,14 @@ func (s *Server) placementsBindings(ctx context.Context, acct *Account, app, hos
// RegionalTarget could never serve it there.
tcp := len(rec.AddrsOrDefault()) > 0
if !ok || rec.Region != b.Region || rec.KindOrDefault() != "instance" || rec.Role != "" || fleet || tcp {
- return nil, &doorRefusal{http.StatusBadRequest, placementsNotInstanceMsg(b.Host, named[i])}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: placementsNotInstanceMsg(b.Host, named[i])}
}
}
if len(s.cfg.RegionIngress) > 0 {
for _, b := range set {
rec := byHost[b.Host]
if rec.HA || s.haRegion(b.Region) {
- return nil, &doorRefusal{http.StatusConflict, s.configuredPlacementGuidance(host)}
+ return nil, &doorRefusal{Status: http.StatusConflict, Msg: s.configuredPlacementGuidance(host)}
}
}
}
@@ -788,7 +788,7 @@ func regionalEvidenceMissing(boxes []status.Box, complete bool, now time.Time) b
// - a fresh heartbeat listing host, "*."+host or "*."+parent among its
// alias rows.
func (s *Server) regionalEvidenceRefusal(ctx context.Context, host string, snap edgesfile.Snapshot, boxes []status.Box, now time.Time) *doorRefusal {
- unreadable := &doorRefusal{http.StatusServiceUnavailable, placementsUnreadableMsg}
+ unreadable := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: placementsUnreadableMsg}
declared, err := provision.RecordHostDeclared(ctx, s.cfg.Releases, host)
if err != nil {
log.Printf("console: api domain placements %s: record walk: %v", host, err)
@@ -799,7 +799,7 @@ func (s *Server) regionalEvidenceRefusal(ctx context.Context, host string, snap
log.Printf("console: api domain placements %s: pending operations: %v", host, err)
return unreadable
}
- taken := &doorRefusal{http.StatusConflict, hostUnavailableMsg}
+ taken := &doorRefusal{Status: http.StatusConflict, Msg: hostUnavailableMsg}
if declared || pending > 0 {
return taken
}
@@ -831,8 +831,8 @@ func (s *Server) regionalEvidenceRefusal(ctx context.Context, host string, snap
// A not-found GET passes; any other GET error is 503 RD-22. Every refusal
// is the neutral 409.
func (s *Server) regionalOverlapRefusal(ctx context.Context, host string, snap edgesfile.Snapshot, boxes []status.Box, now time.Time) *doorRefusal {
- taken := &doorRefusal{http.StatusConflict, hostUnavailableMsg}
- unreadable := &doorRefusal{http.StatusServiceUnavailable, placementsUnreadableMsg}
+ taken := &doorRefusal{Status: http.StatusConflict, Msg: hostUnavailableMsg}
+ unreadable := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: placementsUnreadableMsg}
parent := parentOf(host)
if parent != "" && (publishedHome(snap, "*."+parent) || heartbeatLists(boxes, now, "*."+parent)) {
return taken
@@ -888,7 +888,7 @@ func (s *Server) regionalDescendantRefusal(ctx context.Context, parent string) *
claims, unread, err := s.claims.ListWithUnread(ctx, s.cfg.Releases)
if err != nil {
log.Printf("console: regional descendant scan under %s: %v", parent, err)
- return &doorRefusal{http.StatusServiceUnavailable, placementsUnreadableMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: placementsUnreadableMsg}
}
under := func(h string) bool {
label, ok := strings.CutSuffix(h, "."+parent)
@@ -896,12 +896,12 @@ func (s *Server) regionalDescendantRefusal(ctx context.Context, parent string) *
}
for _, c := range claims {
if c.Regional() && under(c.Host) {
- return &doorRefusal{http.StatusConflict, hostUnavailableMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: hostUnavailableMsg}
}
}
for _, u := range unread {
if under(u.Host) {
- return &doorRefusal{http.StatusConflict, hostUnavailableMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: hostUnavailableMsg}
}
}
return nil
@@ -931,13 +931,13 @@ func regionalReadyRefusal(boxes []status.Box, now time.Time) *doorRefusal {
continue
}
if b.Metrics == nil || b.Metrics.Release == "" {
- return &doorRefusal{http.StatusConflict, placementsNoReleaseMsg(label, floor)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: placementsNoReleaseMsg(label, floor)}
}
- return &doorRefusal{http.StatusConflict, placementsBelowFloorMsg(label, b.Metrics.Release, floor)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: placementsBelowFloorMsg(label, b.Metrics.Release, floor)}
}
for _, label := range labels {
if b := fresh[label]; b.Metrics == nil || !b.Metrics.AliasesRead {
- return &doorRefusal{http.StatusServiceUnavailable, placementsUnreadableMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: placementsUnreadableMsg}
}
}
return nil
@@ -981,10 +981,10 @@ func (s *Server) regionalChannelRefusal(ctx context.Context, boxes []status.Box,
}
if err != nil {
log.Printf("console: regional barrier: system pointer %s: %v", ch, err)
- return &doorRefusal{http.StatusServiceUnavailable, placementsUnreadableMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: placementsUnreadableMsg}
}
if v, ok := release.ParseReleaseVersion(p.Current.Version); !ok || v.Compare(release.RegionalDomainsFloor) < 0 {
- return &doorRefusal{http.StatusConflict, placementsChannelBelowFloorMsg(ch, p.Current.Version, floor)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: placementsChannelBelowFloorMsg(ch, p.Current.Version, floor)}
}
}
return nil
diff --git a/internal/console/apipolicy.go b/internal/console/apipolicy.go
index f9177aae9..ef9264293 100644
--- a/internal/console/apipolicy.go
+++ b/internal/console/apipolicy.go
@@ -383,11 +383,11 @@ func (s *Server) policyStillTheApp(ctx context.Context, acct *Account, app strin
switch {
case err != nil:
s.policyLogf("console: app policy %s/%s: recheck the app: %v", acct.Sqid, app, err)
- return &doorRefusal{http.StatusServiceUnavailable, policyReadFailedMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyReadFailedMsg}
case !ok || now != inc:
s.policyLogf("console: app policy %s/%s: the app was deleted, renamed or moved during the request; nothing written",
acct.Sqid, app)
- return &doorRefusal{http.StatusConflict, policyAppReplacedMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: policyAppReplacedMsg}
}
return nil
}
@@ -590,10 +590,10 @@ func (s *Server) writePolicy(ctx context.Context, acct *Account, app, addr strin
p apppolicy.Policy, next uint64, etag, detail string) (policyReply, *doorRefusal) {
life, lifeErr := s.store.AppLife(acct.ID, app)
if lifeErr != nil || life != nil && life.DemoID != "" && (p.Demo == nil || p.Demo.ID != life.DemoID || p.Demo.Lifetime != life.Lifetime || p.Demo.ExpiresAt != life.ExpiresAt) {
- return policyReply{}, &doorRefusal{http.StatusForbidden, demoCopy["DEMO-POLICY"]}
+ return policyReply{}, &doorRefusal{Status: http.StatusForbidden, Msg: demoCopy["DEMO-POLICY"]}
}
if p.Demo != nil && (life == nil || life.DemoID != p.Demo.ID || !life.Temporary()) {
- return policyReply{}, &doorRefusal{http.StatusForbidden, demo.ErrPolicy.Error()}
+ return policyReply{}, &doorRefusal{Status: http.StatusForbidden, Msg: demo.ErrPolicy.Error()}
}
_, done, ref := s.policyAttempt(ctx, hold)
done()
@@ -602,7 +602,7 @@ func (s *Server) writePolicy(ctx context.Context, acct *Account, app, addr strin
}
if err := s.auditRequired(ctx, acct, app, addr, detail); err != nil {
s.policyLogf("console: app policy %s/%s: audit: %v", acct.Sqid, app, err)
- return policyReply{}, &doorRefusal{http.StatusServiceUnavailable, policyAuditFailedMsg}
+ return policyReply{}, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyAuditFailedMsg}
}
p.Account, p.App, p.Revision, p.SignedAt = acct.Sqid, app, next, time.Now().UTC()
_, done, ref = s.policyAttempt(ctx, hold)
@@ -613,11 +613,11 @@ func (s *Server) writePolicy(ctx context.Context, acct *Account, app, addr strin
done()
if err != nil {
s.policyLogf("console: app policy %s/%s: sign: %v", acct.Sqid, app, err)
- return policyReply{}, &doorRefusal{http.StatusServiceUnavailable, policyRecordFailedMsg}
+ return policyReply{}, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyRecordFailedMsg}
}
if err := s.store.RecordAppPolicyContext(ctx, acct.ID, app, next, wire); err != nil {
s.policyLogf("console: app policy %s/%s: record revision %d: %v", acct.Sqid, app, next, err)
- return policyReply{}, &doorRefusal{http.StatusServiceUnavailable, policyRecordFailedMsg}
+ return policyReply{}, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyRecordFailedMsg}
}
// The content this holding builds on is now the table's.
s.markPolicyTouched(acct.Sqid+"/"+app, hold.n)
@@ -644,8 +644,8 @@ func (s *Server) writePolicy(ctx context.Context, acct *Account, app, addr strin
// recreated; a create whose object is still absent is tried again as a create.
func (s *Server) publishPolicy(ctx context.Context, acct *Account, app string, hold policyHolding,
wire []byte, next uint64, etag string) (string, *doorRefusal) {
- lost := &doorRefusal{http.StatusServiceUnavailable, policyLeaseLostMsg}
- unpublished := &doorRefusal{http.StatusBadGateway, policyUnpublishedMsg}
+ lost := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyLeaseLostMsg}
+ unpublished := &doorRefusal{Status: http.StatusBadGateway, Msg: policyUnpublishedMsg}
pub := s.policyPub()
created := etag == ""
for attempt := 0; attempt < doorKeyPublishAttempts; attempt++ {
diff --git a/internal/console/apiship_rootfs.go b/internal/console/apiship_rootfs.go
index fd8868bfa..97d877e59 100644
--- a/internal/console/apiship_rootfs.go
+++ b/internal/console/apiship_rootfs.go
@@ -104,20 +104,20 @@ func refuseUnread(w http.ResponseWriter, status int, msg string) {
// declared image size within the limit. It returns the processes.
func rootfsMetaRefusal(meta shipMeta) (map[string]release.Process, *doorRefusal) {
if len(meta.Capabilities) > 0 {
- return nil, &doorRefusal{http.StatusBadRequest, release.ErrRootfsCapabilities.Error()}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: release.ErrRootfsCapabilities.Error()}
}
procs, err := release.DecodeProcesses(meta.Processes)
if err == nil {
err = release.ValidateProcesses(procs)
}
if err != nil {
- return nil, &doorRefusal{http.StatusBadRequest, err.Error()}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: err.Error()}
}
if meta.RootfsSize <= 0 {
- return nil, &doorRefusal{http.StatusBadRequest, "the request does not say how large the rootfs image is, so nothing was read. update carlos and ship again"}
+ return nil, &doorRefusal{Status: http.StatusBadRequest, Msg: "the request does not say how large the rootfs image is, so nothing was read. update carlos and ship again"}
}
if meta.RootfsSize > apiShipMaxBytesRootfs {
- return nil, &doorRefusal{http.StatusRequestEntityTooLarge, "the rootfs image is over 2 GiB, the most one release can carry. make the image smaller and ship again"}
+ return nil, &doorRefusal{Status: http.StatusRequestEntityTooLarge, Msg: "the rootfs image is over 2 GiB, the most one release can carry. make the image smaller and ship again"}
}
return procs, nil
}
@@ -359,9 +359,9 @@ func (s *Server) fixFirstRootfsKind(ctx context.Context, acct *Account, m *relea
}
log.Printf("console: api ship %s/%s %s: first kind: %v", acct.Sqid, m.App, m.Version, err)
if msg, ok := shipKindConflict(err); ok {
- return &doorRefusal{http.StatusConflict, msg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msg}
}
- return &doorRefusal{http.StatusServiceUnavailable, shipKindUnchecked}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: shipKindUnchecked}
}
// fixFirstRootfsKindLocked is fixFirstRootfsKind's part under the app
diff --git a/internal/console/apisidecars.go b/internal/console/apisidecars.go
index 37b351c2f..dba96fed0 100644
--- a/internal/console/apisidecars.go
+++ b/internal/console/apisidecars.go
@@ -411,8 +411,8 @@ func (s *Server) handleAPISidecarCreate(w http.ResponseWriter, r *http.Request)
return err == nil, err
},
// The same two answers the CreateSidecarRecord call below gives.
- duplicate: doorRefusal{http.StatusConflict, "sidecar " + name + " already exists"},
- readFailed: doorRefusal{http.StatusBadGateway, "could not create the sidecar — try again"},
+ duplicate: doorRefusal{Status: http.StatusConflict, Msg: "sidecar " + name + " already exists"},
+ readFailed: doorRefusal{Status: http.StatusBadGateway, Msg: "could not create the sidecar — try again"},
taken: "the name " + name + " still holds data from a deleted sidecar. Choose another name, or ask an operator to purge it.",
unsure: "could not check whether the name " + name + " is free. Try again.",
}); ref != nil {
diff --git a/internal/console/appdomainbuy.go b/internal/console/appdomainbuy.go
index 0e4f9a593..7490415e1 100644
--- a/internal/console/appdomainbuy.go
+++ b/internal/console/appdomainbuy.go
@@ -98,7 +98,7 @@ func (s *Server) domainBuyBrowserGate(w http.ResponseWriter, r *http.Request) (s
return "", "", nil, "", false
}
if !s.allowDomains(Principal{Kind: PrincipalUser, Address: addr}, time.Now()) {
- s.renderDoorRefusal(w, r, &doorRefusal{429, domainBuyCopy["rate"]})
+ s.renderDoorRefusal(w, r, &doorRefusal{Status: 429, Msg: domainBuyCopy["rate"]})
return "", "", nil, "", false
}
w.Header().Set("Cache-Control", "no-store")
diff --git a/internal/console/appregionset.go b/internal/console/appregionset.go
index 795291501..9624c826f 100644
--- a/internal/console/appregionset.go
+++ b/internal/console/appregionset.go
@@ -266,16 +266,16 @@ func (s *Server) setAppRegion(ctx context.Context, acct *Account, app string, fo
// operation, and this one has none: refused before anything is read
// (host claims are shelved; claimRenameUnsupportedMsg is the precedent).
if s.cfg.HostClaim {
- return appRegionView{}, &doorRefusal{http.StatusConflict, appRegionSetCopy.ClaimOff}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: appRegionSetCopy.ClaimOff}
}
// With no home named, the home has no code to choose, so a change away
// from it could never be undone here.
if s.regionHome() == "" {
- return appRegionView{}, &doorRefusal{http.StatusConflict, appRegionSetCopy.NoHome}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: appRegionSetCopy.NoHome}
}
raw = strings.TrimSpace(raw)
if raw == "" {
- return appRegionView{}, &doorRefusal{http.StatusBadRequest, appRegionSetCopy.NoRegion}
+ return appRegionView{}, &doorRefusal{Status: http.StatusBadRequest, Msg: appRegionSetCopy.NoRegion}
}
code := s.homeRegionIn(raw)
choices, ref := s.appRegionChoices(ctx)
@@ -284,9 +284,9 @@ func (s *Server) setAppRegion(ctx context.Context, acct *Account, app string, fo
}
if (code != "" && !provision.ValidRegion(code)) || !slices.Contains(choices, s.homeRegionOut(code)) {
if len(choices) == 0 {
- return appRegionView{}, &doorRefusal{http.StatusBadRequest, fmt.Sprintf(appRegionSetCopy.NotOfferedNone, raw)}
+ return appRegionView{}, &doorRefusal{Status: http.StatusBadRequest, Msg: fmt.Sprintf(appRegionSetCopy.NotOfferedNone, raw)}
}
- return appRegionView{}, &doorRefusal{http.StatusBadRequest, fmt.Sprintf(appRegionSetCopy.NotOffered, raw, strings.Join(choices, ", "))}
+ return appRegionView{}, &doorRefusal{Status: http.StatusBadRequest, Msg: fmt.Sprintf(appRegionSetCopy.NotOffered, raw, strings.Join(choices, ", "))}
}
// The region must also be able to take an instance now, by the same
// positive test the create door puts an app-derived region to
@@ -298,25 +298,25 @@ func (s *Server) setAppRegion(ctx context.Context, acct *Account, app string, fo
if err != nil {
log.Printf("console: app region %s/%s: read edges: %v", acct.Sqid, app, err)
}
- return appRegionView{}, &doorRefusal{http.StatusServiceUnavailable, fmt.Sprintf(appRegionSetCopy.Unconfirmed, raw)}
+ return appRegionView{}, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: fmt.Sprintf(appRegionSetCopy.Unconfirmed, raw)}
}
reason := "absent"
if c, ok := findCandidate(s.regionCands(snap), code); ok {
reason = c.unavailableReason()
}
if reason != "" {
- return appRegionView{}, &doorRefusal{http.StatusConflict, fmt.Sprintf(appRegionSetCopy.Unavailable, raw, reasonText(reason))}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(appRegionSetCopy.Unavailable, raw, reasonText(reason))}
}
}
pol := s.appPolicy(ctx, acct, app)
switch {
case pol.State == policyUnreadable:
- return appRegionView{}, &doorRefusal{http.StatusBadGateway, appRegionSetCopy.PolicyUnread}
+ return appRegionView{}, &doorRefusal{Status: http.StatusBadGateway, Msg: appRegionSetCopy.PolicyUnread}
case pol.Placed != "":
name, _ := strings.CutPrefix(pol.Placed, "fleet/")
- return appRegionView{}, &doorRefusal{http.StatusConflict, fmt.Sprintf(appRegionSetCopy.OnFleet, app, name)}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(appRegionSetCopy.OnFleet, app, name)}
case pol.pooled():
- return appRegionView{}, &doorRefusal{http.StatusConflict, fmt.Sprintf(appRegionSetCopy.Pooled, app)}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(appRegionSetCopy.Pooled, app)}
case !pol.allows(code):
var allowed []string
for _, c := range choices {
@@ -325,24 +325,24 @@ func (s *Server) setAppRegion(ctx context.Context, acct *Account, app string, fo
}
}
if len(allowed) == 0 {
- return appRegionView{}, &doorRefusal{http.StatusConflict, fmt.Sprintf(appRegionSetCopy.NotAllowedNone, raw)}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(appRegionSetCopy.NotAllowedNone, raw)}
}
- return appRegionView{}, &doorRefusal{http.StatusConflict, fmt.Sprintf(appRegionSetCopy.NotAllowed, raw, strings.Join(allowed, ", "))}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(appRegionSetCopy.NotAllowed, raw, strings.Join(allowed, ", "))}
}
defer s.lockApp(acct.Sqid, app)()
inc, live, err := s.store.AppIncarnationContext(ctx, acct.ID, app)
if err != nil {
log.Printf("console: app region %s/%s: incarnation: %v", acct.Sqid, app, err)
- return appRegionView{}, &doorRefusal{http.StatusInternalServerError, appRegionSetCopy.WriteFailed}
+ return appRegionView{}, &doorRefusal{Status: http.StatusInternalServerError, Msg: appRegionSetCopy.WriteFailed}
}
if !live || inc != found {
- return appRegionView{}, &doorRefusal{http.StatusConflict, appRegionSetCopy.Changed}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: appRegionSetCopy.Changed}
}
from, fromSource, err := s.store.AppRegion(acct.ID, app)
if err != nil {
log.Printf("console: app region %s/%s: read: %v", acct.Sqid, app, err)
- return appRegionView{}, &doorRefusal{http.StatusBadGateway, msgAppRegionUnreadable}
+ return appRegionView{}, &doorRefusal{Status: http.StatusBadGateway, Msg: msgAppRegionUnreadable}
}
home, names := s.regionHome(), s.regionNames()
newLabel := regionlabel.ForCode(code, home, names)
@@ -355,10 +355,10 @@ func (s *Server) setAppRegion(ctx context.Context, acct *Account, app string, fo
ok, err := s.store.SetAppRegion(ctx, acct.ID, app, inc, from, code, time.Now())
if err != nil {
log.Printf("console: app region %s/%s: write: %v", acct.Sqid, app, err)
- return appRegionView{}, &doorRefusal{http.StatusInternalServerError, appRegionSetCopy.WriteFailed}
+ return appRegionView{}, &doorRefusal{Status: http.StatusInternalServerError, Msg: appRegionSetCopy.WriteFailed}
}
if !ok {
- return appRegionView{}, &doorRefusal{http.StatusConflict, appRegionSetCopy.Changed}
+ return appRegionView{}, &doorRefusal{Status: http.StatusConflict, Msg: appRegionSetCopy.Changed}
}
detail := fmt.Sprintf(appRegionSetCopy.AuditChanged, app, oldLabel.Text, newLabel.Text)
if via != "" {
@@ -376,7 +376,7 @@ func (s *Server) setAppRegion(ctx context.Context, acct *Account, app string, fo
// files, per change; never on a page view.
func (s *Server) appRegionChoices(ctx context.Context) ([]string, *doorRefusal) {
if s.cfg.Releases == nil {
- return nil, &doorRefusal{http.StatusServiceUnavailable, appRegionSetCopy.OptionsUnread}
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: appRegionSetCopy.OptionsUnread}
}
return s.explicitChoices(s.readExplicitGate(ctx)), nil
}
diff --git a/internal/console/claim_first_route.go b/internal/console/claim_first_route.go
index 85a2c5ed5..d313aa1c9 100644
--- a/internal/console/claim_first_route.go
+++ b/internal/console/claim_first_route.go
@@ -26,7 +26,7 @@ func (s *Server) attachClaimFirstRoute(ctx context.Context, acct *Account, app,
return attachResult{}, claimRefusal(host, domains.ErrRegionalClaim)
}
if !s.domainProver(ctx, host, acct.Sqid)() {
- return attachResult{}, &doorRefusal{http.StatusConflict, verifyGuidance(s.domainChallenge(host, acct.Sqid))}
+ return attachResult{}, &doorRefusal{Status: http.StatusConflict, Msg: verifyGuidance(s.domainChallenge(host, acct.Sqid))}
}
request, err := s.beginClaimCreate(ctx, acct, app, host, principal, func(now time.Time, acquisition string) (hostops.Record, error) {
rec := provision.Record{Schema: 1, Host: host, App: app, Account: acct.Sqid, Channel: channel, Kind: "static", CreatedBy: principal, Acquisition: acquisition}
diff --git a/internal/console/claim_response.go b/internal/console/claim_response.go
index b48535d94..4ddb81eb7 100644
--- a/internal/console/claim_response.go
+++ b/internal/console/claim_response.go
@@ -18,12 +18,12 @@ func claimResponseRefusal(err error) *doorRefusal {
// No box has room (region HA spec 2 §7, H27): every create door's 503.
var full *noCapacityError
if errors.As(err, &full) {
- return &doorRefusal{http.StatusServiceUnavailable, noCapacityRefusal(full.Region)}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: noCapacityRefusal(full.Region)}
}
if errors.Is(err, hostops.ErrPending) || errors.Is(err, hostclaim.ErrConflict) || errors.Is(err, hostclaim.ErrWrongState) || errors.Is(err, release.ErrCASConflict) {
- return &doorRefusal{http.StatusConflict, claimRetireBusyMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: claimRetireBusyMsg}
}
- return &doorRefusal{http.StatusServiceUnavailable, claimResponseUnavailable}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: claimResponseUnavailable}
}
func writeClaimResponseError(w http.ResponseWriter, err error) {
diff --git a/internal/console/createleftovers.go b/internal/console/createleftovers.go
index 4a1901c5d..ad12d788c 100644
--- a/internal/console/createleftovers.go
+++ b/internal/console/createleftovers.go
@@ -161,20 +161,20 @@ func (s *Server) leftoverReplicaRefusal(parent context.Context, c leftoverCreate
if c.HAData {
name := s.offlineName(c.region)
if s.homeRegionIn(c.region) != "" || c.pool != "" {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("high availability data creation is not available yet in %s. use the console's home region without a pool.", name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("high availability data creation is not available yet in %s. use the console's home region without a pool.", name)}
}
unsure = fmt.Sprintf("could not check this instance's data in %s. nothing was created. try again. persistent failures may require an operator to check home data access.", name)
if s.cfg.SeedData == nil || !s.leftoverCheckApplies(c.region, c.pool) {
- return &doorRefusal{http.StatusServiceUnavailable, unsure}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: unsure}
}
prefix := activator.HibernatePrefix(s.cfg.HibernatePrefix, c.host) + "/"
class, proofErr := firstHALeftover(ctx, s.cfg.SeedData, prefix)
if proofErr != nil {
log.Printf("console: %s: HA prefix check for %s: %v", c.logTag, c.host, proofErr)
- return &doorRefusal{http.StatusServiceUnavailable, unsure}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: unsure}
}
if class != "" {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s still holds %s from a deleted instance. choose another address, or ask an operator to purge it.", c.host, class)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s still holds %s from a deleted instance. choose another address, or ask an operator to purge it.", c.host, class)}
}
// The whole-prefix proof covered every instance level. Move staging
// remains a separate prefix and must still be checked at all levels.
@@ -185,11 +185,11 @@ func (s *Server) leftoverReplicaRefusal(parent context.Context, c leftoverCreate
}
if err != nil {
log.Printf("console: %s: leftover replica check for %s: %v", c.logTag, c.host, err)
- return &doorRefusal{http.StatusServiceUnavailable, unsure}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: unsure}
}
if held {
log.Printf("console: %s: refused: %s still holds replica data from a deleted record (#199); purge it to free the host", c.logTag, c.host)
- return &doorRefusal{http.StatusConflict, taken}
+ return &doorRefusal{Status: http.StatusConflict, Msg: taken}
}
return nil
}
diff --git a/internal/console/demo_data.go b/internal/console/demo_data.go
index a3afe6385..08513e49d 100644
--- a/internal/console/demo_data.go
+++ b/internal/console/demo_data.go
@@ -8,5 +8,5 @@ func init() {
}
func demoDataRefusal() *doorRefusal {
- return &doorRefusal{http.StatusConflict, demoCopy["DEMO-DATA"]}
+ return &doorRefusal{Status: http.StatusConflict, Msg: demoCopy["DEMO-DATA"]}
}
diff --git a/internal/console/demo_domains.go b/internal/console/demo_domains.go
index b9a488aba..7e4710be8 100644
--- a/internal/console/demo_domains.go
+++ b/internal/console/demo_domains.go
@@ -21,10 +21,10 @@ func (s *Server) demoMutationRefusal(acct *Account, app string) *doorRefusal {
life, err := s.store.AppLife(acct.ID, app)
if err != nil {
log.Printf("console: demo mutation %s/%s: app life: %v", acct.Sqid, app, err)
- return &doorRefusal{http.StatusServiceUnavailable, demoCopy["DEMO-CHECK-FAILED"]}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: demoCopy["DEMO-CHECK-FAILED"]}
}
if life != nil && life.DemoID != "" {
- return &doorRefusal{http.StatusConflict, demoCopy["DEMO-POLICY"]}
+ return &doorRefusal{Status: http.StatusConflict, Msg: demoCopy["DEMO-POLICY"]}
}
return nil
}
@@ -42,5 +42,5 @@ func (s *Server) demoRecordReservation(ctx context.Context, rec provision.Record
rec.Region == "fleet/"+s.cfg.Demo.Fleet {
return nil
}
- return &hostsUsedError{doorRefusal{http.StatusConflict, demoCopy["DEMO-POLICY"]}}
+ return &hostsUsedError{doorRefusal{Status: http.StatusConflict, Msg: demoCopy["DEMO-POLICY"]}}
}
diff --git a/internal/console/domainattach.go b/internal/console/domainattach.go
index e12073184..996018853 100644
--- a/internal/console/domainattach.go
+++ b/internal/console/domainattach.go
@@ -72,8 +72,9 @@ import (
// member-facing and NEVER names another account: the 409 below is one
// string whoever holds the host, including the caller.
type doorRefusal struct {
- Status int
- Msg string
+ Status int
+ Msg string
+ haCapacityRetryAfter int
}
// attachResult is what the doors report back. FirstRoute distinguishes the
@@ -130,15 +131,15 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
// same pair the CLI API door runs — one validation spot, two doors.
host, ok := domains.NormalizeAliasHost(host)
if !ok {
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "not a valid hostname — attach a full hostname like tickets.example.com"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "not a valid hostname — attach a full hostname like tickets.example.com"}
}
if err := s.demoRecordReservation(ctx, provision.Record{Host: host}); err != nil {
- return attachResult{}, &doorRefusal{http.StatusConflict, demoCopy["DEMO-POLICY"]}
+ return attachResult{}, &doorRefusal{Status: http.StatusConflict, Msg: demoCopy["DEMO-POLICY"]}
}
if policy := s.domainHostPolicy(host, acct.Sqid); policy == hostReserved || (policy == hostPlatform && !platform) {
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "that hostname is platform-managed"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "that hostname is platform-managed"}
}
// Plans 3a: custom domains need a plan that includes them.
if ref := s.customDomainRefusal(acct, host); ref != nil {
@@ -151,14 +152,14 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
// a Kind=="sidecar" row (edge.go's Reload) — this closes the other
// direction, a member attaching an unrelated app's domain under it.
if strings.HasSuffix(host, provision.SidecarSuffix) {
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "that hostname is reserved for sidecar processes"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "that hostname is reserved for sidecar processes"}
}
route, selfChannel, err := s.readyRouteHost(acct.Sqid, app, host)
if err != nil {
log.Printf("console: attach %s: registry: %v", host, err)
- return attachResult{}, &doorRefusal{http.StatusInternalServerError,
- "could not read this deployment's routes — try again in a moment"}
+ return attachResult{}, &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not read this deployment's routes — try again in a moment"}
}
claim := domains.Claim{
Schema: 1, Host: host, Account: acct.Sqid, App: app, Route: route,
@@ -196,17 +197,17 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
}
if s.directAppsDomainHost(host) {
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity, hostUnavailableMsg}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: hostUnavailableMsg}
}
if s.firstRouteOutsideNamespace(host, acct.Sqid) {
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "that hostname is platform-managed"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "that hostname is platform-managed"}
}
// --- first-route attach: this host becomes the app's primary --------
if kindFlag != "" && kindFlag != "static" {
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "an app with no running route can only attach a static domain — deploy first, then attach"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "an app with no running route can only attach a static domain — deploy first, then attach"}
}
channel, ref := s.attachChannel(ctx, acct.Sqid, app, channelFlag, selfChannel)
if ref != nil {
@@ -217,9 +218,9 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
defer s.planLock(acct)()
if err := s.checkRunningThings(ctx, acct, 1); err != nil {
if isPlanCap(err) {
- return attachResult{}, &doorRefusal{http.StatusConflict, err.Error()}
+ return attachResult{}, &doorRefusal{Status: http.StatusConflict, Msg: err.Error()}
}
- return attachResult{}, &doorRefusal{http.StatusBadGateway, "could not create the instance — try again"}
+ return attachResult{}, &doorRefusal{Status: http.StatusBadGateway, Msg: "could not create the instance — try again"}
}
if ref := s.heldElsewhere(ctx, host, acct.Sqid, app); ref != nil {
return attachResult{}, ref
@@ -228,7 +229,7 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
// A standing first-route record is a reattachment, not a new create.
existing, _, readErr := s.readRecord(ctx, acct.Sqid, app, host)
if readErr != nil && !errors.Is(readErr, os.ErrNotExist) {
- return attachResult{}, &doorRefusal{http.StatusBadGateway, "could not create the instance — try again"}
+ return attachResult{}, &doorRefusal{Status: http.StatusBadGateway, Msg: "could not create the instance — try again"}
}
if existing == nil {
if ref := s.requireHACreateCapacity(ctx, "", ""); ref != nil {
@@ -270,7 +271,7 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
// instance record (edge asset cache design §6).
if err := provision.EnsureAssetGen(&rec); err != nil {
log.Printf("console: attach %s/%s %s: %v", acct.Sqid, app, host, err)
- return attachResult{}, &doorRefusal{http.StatusBadGateway, "could not create the instance — try again"}
+ return attachResult{}, &doorRefusal{Status: http.StatusBadGateway, Msg: "could not create the instance — try again"}
}
if err := s.withRecordLock(rec.Account, rec.App, func() error { return provision.CreateRecord(ctx, s.cfg.Releases, rec) }); err != nil {
// A record already at this key is NOT a failure to undo. The key is
@@ -307,8 +308,8 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
// wrote it.
log.Printf("console: attach %s: existing record is not this door's to adopt (read: %v)", host, gerr)
s.rollbackAttach(ctx, acct, app, host, false, created)
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "a route record already exists for this host — detach it or pick another hostname"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "a route record already exists for this host — detach it or pick another hostname"}
}
// Anything else is AMBIGUOUS: a timeout or a dropped connection can
// come back as an error for a write that landed. Unwind both, in
@@ -317,8 +318,8 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k
// anyone may now claim.
log.Printf("console: attach %s: record write: %v", host, err)
s.rollbackAttach(ctx, acct, app, host, true, created)
- return attachResult{}, &doorRefusal{http.StatusInternalServerError,
- "could not declare the route for this domain — nothing was attached, try again"}
+ return attachResult{}, &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not declare the route for this domain — nothing was attached, try again"}
}
// The record wrote (a real change by definition), so this announces
// regardless of whether the claim half was the no-op of a retry.
@@ -351,9 +352,9 @@ func (s *Server) detachDomain(ctx context.Context, acct *Account, app, host, pri
// its own caller (handleAppDomainDetach) has already spent the session,
// CSRF and owner gates, so a non-member never reaches this sentence.
if msg, status := s.controlPlaneRefusal(acct, app, "detached"); msg != "" {
- return &doorRefusal{status, msg}
+ return &doorRefusal{Status: status, Msg: msg}
}
- notAttached := &doorRefusal{http.StatusNotFound, "not attached to this app"}
+ notAttached := &doorRefusal{Status: http.StatusNotFound, Msg: "not attached to this app"}
// A host that is not even a hostname cannot be a claim key: refuse it
// here rather than handing it to a store as a key segment.
host, ok := domains.NormalizeAliasHost(host)
@@ -366,7 +367,7 @@ func (s *Server) detachDomain(ctx context.Context, acct *Account, app, host, pri
// claim one now, and a member holding one from before it was reserved
// must still be able to let it go.
if s.domainHostPolicy(host, acct.Sqid) == hostPlatform && !s.platformOperator(principal) {
- return &doorRefusal{http.StatusForbidden, platformOperatorMsg}
+ return &doorRefusal{Status: http.StatusForbidden, Msg: platformOperatorMsg}
}
if lifetimesUnit(ctx) {
// Admitted on: the claim read, the record and the claim release
@@ -380,8 +381,8 @@ func (s *Server) detachDomain(ctx context.Context, acct *Account, app, host, pri
return notAttached
}
log.Printf("console: detach %s: claim read: %v", host, err)
- return &doorRefusal{http.StatusInternalServerError,
- "could not read this domain's claim — try again in a moment"}
+ return &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not read this domain's claim — try again in a moment"}
}
if claim.Account != acct.Sqid || claim.App != app {
return notAttached
@@ -392,8 +393,8 @@ func (s *Server) detachDomain(ctx context.Context, acct *Account, app, host, pri
ref, err := s.detachRetireLocked(ctx, acct.Sqid, app, host)
if err != nil {
log.Printf("console: detach %s: record delete: %v", host, err)
- return &doorRefusal{http.StatusInternalServerError,
- "could not remove this domain's route — it is still attached, try again"}
+ return &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not remove this domain's route — it is still attached, try again"}
}
if ref != nil {
return ref
@@ -409,14 +410,14 @@ func (s *Server) detachDomain(ctx context.Context, acct *Account, app, host, pri
if accepted, ok := claimRetireAcceptedOf(err); ok {
s.audit(acct, app, principal, "domain-detach", "removal of the route for "+host+" accepted, operation "+accepted.operation)
s.bumpSerial(ctx)
- return &doorRefusal{http.StatusConflict, claimDetachInProgressMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: claimDetachInProgressMsg}
}
if errors.Is(err, hostops.ErrPending) {
- return &doorRefusal{http.StatusConflict, claimRetireBusyMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: claimRetireBusyMsg}
}
log.Printf("console: detach %s: record delete: %v", host, err)
- return &doorRefusal{http.StatusInternalServerError,
- "could not remove this domain's route — it is still attached, try again"}
+ return &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not remove this domain's route — it is still attached, try again"}
}
}
// DetachClaim re-checks ownership before deleting (its own neutrality);
@@ -425,15 +426,15 @@ func (s *Server) detachDomain(ctx context.Context, acct *Account, app, host, pri
// announces.
removed, err := s.detachDomainClaim(ctx, host, acct.Sqid, app)
if msg, ok := claimAliasRefusal(err); ok {
- return &doorRefusal{http.StatusConflict, msg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msg}
}
if errors.Is(err, hostops.ErrContract) {
- return &doorRefusal{http.StatusConflict, err.Error()}
+ return &doorRefusal{Status: http.StatusConflict, Msg: err.Error()}
}
if err != nil {
log.Printf("console: detach %s: claim delete: %v", host, err)
- return &doorRefusal{http.StatusInternalServerError,
- "could not release this domain's claim — try again in a moment"}
+ return &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not release this domain's claim — try again in a moment"}
}
if removed {
s.audit(acct, app, principal, "domain-detach", host)
@@ -550,7 +551,7 @@ func (s *Server) attachChannel(ctx context.Context, sqid, app, channelFlag, self
// the instance-create door puts on its own channel field).
if channelFlag != "" {
if !release.ValidChannel(channelFlag) {
- return "", &doorRefusal{http.StatusUnprocessableEntity, "invalid channel name"}
+ return "", &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: "invalid channel name"}
}
return channelFlag, nil
}
@@ -561,8 +562,8 @@ func (s *Server) attachChannel(ctx context.Context, sqid, app, channelFlag, self
keys, err := s.cfg.Releases.List(ctx, prefix)
if err != nil {
log.Printf("console: attach: list channels %s/%s: %v", sqid, app, err)
- return "", &doorRefusal{http.StatusInternalServerError,
- "could not list this app's channels — try again in a moment"}
+ return "", &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not list this app's channels — try again in a moment"}
}
var names []string
for _, k := range keys {
@@ -575,13 +576,13 @@ func (s *Server) attachChannel(ctx context.Context, sqid, app, channelFlag, self
sort.Strings(names)
switch len(names) {
case 0:
- return "", &doorRefusal{http.StatusUnprocessableEntity,
- "nothing shipped yet — carlos ship first"}
+ return "", &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "nothing shipped yet — carlos ship first"}
case 1:
return names[0], nil
}
- return "", &doorRefusal{http.StatusUnprocessableEntity,
- "this app follows several channels (" + strings.Join(names, ", ") +
+ return "", &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "this app follows several channels (" + strings.Join(names, ", ") +
") — say which one this domain serves"}
}
@@ -605,8 +606,8 @@ func attachWrote(rec provision.Record) bool {
// member meets it.
func (s *Server) bucketRefusal() *doorRefusal {
if s.cfg.Releases == nil {
- return &doorRefusal{http.StatusServiceUnavailable,
- "no deployment bucket on this host — the console is running without one"}
+ return &doorRefusal{Status: http.StatusServiceUnavailable,
+ Msg: "no deployment bucket on this host — the console is running without one"}
}
return nil
}
@@ -656,7 +657,7 @@ func (s *Server) attachFirstRouteWithLifetime(ctx context.Context, acct *Account
life, err := s.store.AppLife(acct.ID, app)
if err != nil {
log.Printf("console: attach %s: read the app: %v", host, err)
- return attachResult{}, &doorRefusal{http.StatusBadGateway, msgLifetimeAppUnreadable}
+ return attachResult{}, &doorRefusal{Status: http.StatusBadGateway, Msg: msgLifetimeAppUnreadable}
}
lifetime := ""
if life != nil {
@@ -692,8 +693,8 @@ func (s *Server) attachFirstRouteLocked(ctx context.Context, acct *Account, app,
CreatedAt: time.Now().UTC(), CreatedBy: principal,
}
rec.HA = s.shouldStampHA(rec) // never true for a static record
- ambiguous := &doorRefusal{http.StatusInternalServerError,
- "could not declare the route for this domain — nothing was attached, try again"}
+ ambiguous := &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not declare the route for this domain — nothing was attached, try again"}
_, err = s.createRecordWithLifetimeLocked(ctx, rec, lifetime)
switch {
case err == nil:
@@ -719,8 +720,8 @@ func (s *Server) attachFirstRouteLocked(ctx context.Context, acct *Account, app,
}
log.Printf("console: attach %s: existing record is not this door's to adopt (read: %v)", host, gerr)
s.rollbackAttachLocked(ctx, acct, app, host, created)
- return attachResult{}, &doorRefusal{http.StatusUnprocessableEntity,
- "a route record already exists for this host — detach it or pick another hostname"}
+ return attachResult{}, &doorRefusal{Status: http.StatusUnprocessableEntity,
+ Msg: "a route record already exists for this host — detach it or pick another hostname"}
}
log.Printf("console: attach %s: record write: %v", host, err)
s.rollbackAttachLocked(ctx, acct, app, host, created)
@@ -768,27 +769,27 @@ func (s *Server) rollbackAttachLocked(ctx context.Context, acct *Account, app, h
// diffed against each other to learn anything either one refuses to say.
func claimRefusal(host string, err error) *doorRefusal {
if msg, ok := claimAliasRefusal(err); ok {
- return &doorRefusal{http.StatusConflict, msg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msg}
}
if errors.Is(err, hostops.ErrPending) {
- return &doorRefusal{http.StatusConflict, claimRetireBusyMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: claimRetireBusyMsg}
}
if errors.Is(err, hostops.ErrContract) {
- return &doorRefusal{http.StatusConflict, err.Error()}
+ return &doorRefusal{Status: http.StatusConflict, Msg: err.Error()}
}
if errors.Is(err, domains.ErrHostUnavailable) {
- return &doorRefusal{http.StatusConflict, hostUnavailableMsg}
+ return &doorRefusal{Status: http.StatusConflict, Msg: hostUnavailableMsg}
}
// The caller's own regional claim (#447): every writer answers it only
// after its owner match, so this names nobody else's hostname. RD-26
// here; a door with its own words for it (the catch-all door) answers
// it before calling this.
if errors.Is(err, domains.ErrRegionalClaim) {
- return &doorRefusal{http.StatusConflict, domains.ErrRegionalClaim.Error()}
+ return &doorRefusal{Status: http.StatusConflict, Msg: domains.ErrRegionalClaim.Error()}
}
log.Printf("console: attach %s: claim write: %v", host, err)
- return &doorRefusal{http.StatusInternalServerError,
- "could not claim this domain — try again in a moment"}
+ return &doorRefusal{Status: http.StatusInternalServerError,
+ Msg: "could not claim this domain — try again in a moment"}
}
// platformNote marks an audit row written through the platform door (#209),
diff --git a/internal/console/domainbuy.go b/internal/console/domainbuy.go
index cc0436649..8f5c49c8e 100644
--- a/internal/console/domainbuy.go
+++ b/internal/console/domainbuy.go
@@ -28,7 +28,7 @@ func (s *Server) domainPurchaseReady() bool {
}
func domainBuyUnavailable() *doorRefusal {
- return &doorRefusal{http.StatusServiceUnavailable, domainBuyCopy["unavailable"]}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: domainBuyCopy["unavailable"]}
}
// admitDomainBuy is shared by every check and purchase door after owner/person
@@ -84,7 +84,7 @@ func (s *Server) admitDomainBuy(ctx context.Context, acct *Account, name string,
return domainreg.Quote{}, domainBuyStateRefusal("currency", http.StatusUnprocessableEntity)
}
if !s.domainChecks.allow(acct.ID) {
- return domainreg.Quote{}, &doorRefusal{http.StatusTooManyRequests, domainBuyCopy["rate"]}
+ return domainreg.Quote{}, &doorRefusal{Status: http.StatusTooManyRequests, Msg: domainBuyCopy["rate"]}
}
a, err := s.cfg.Registrar.Check(ctx, name)
if err != nil {
@@ -154,7 +154,7 @@ func (s *Server) startDomainPurchase(ctx context.Context, acct *Account, app, na
return nil, "", nil, &doorRefusal{Status: http.StatusNotFound}
}
if err := c.Validate(); err != nil {
- return nil, "", nil, &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["contactError"]}
+ return nil, "", nil, &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]}
}
h, release, err := s.holdBilling(acct)
if err != nil {
@@ -186,7 +186,7 @@ func (s *Server) startDomainPurchase(ctx context.Context, acct *Account, app, na
}
if count >= s.cfg.DomainCatalog.DailyCap {
release()
- return nil, "", nil, &doorRefusal{http.StatusTooManyRequests, domainPurchaseCopy.DailyCap}
+ return nil, "", nil, &doorRefusal{Status: http.StatusTooManyRequests, Msg: domainPurchaseCopy.DailyCap}
}
balance, err := s.cfg.Registrar.Balance(ctx)
if err != nil {
@@ -258,7 +258,7 @@ func (s *Server) resumeDomainPurchase(ctx context.Context, p *DomainPurchase) (*
return p, "", domainBuyStateRefusal("billingSetup", http.StatusServiceUnavailable)
}
if p.State == PurchaseFailed && p.Reason == "contact" {
- return p, "", &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["contactError"]}
+ return p, "", &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]}
}
return p, "", domainBuyUnavailable()
}
@@ -571,23 +571,29 @@ func (s *Server) advancePurchaseEffects(ctx context.Context, acct *Account, p *D
}
return billing.ErrIndeterminate
case PurchaseCaptured:
- // Claim the attempt before either attach so concurrent calls do not lose its count.
- if err := s.movePurchase(ctx, p, p.State, func(p *DomainPurchase) { p.Attempts++ }); err != nil {
+ // Reserve this revision before either attach; capacity refusals do not count as attempts.
+ if err := s.movePurchase(ctx, p, p.State, nil); err != nil {
return err
}
for _, host := range []string{p.Domain, "www." + p.Domain} {
_, ref := s.attachDomain(ctx, acct, p.App, host, "", "", p.Principal)
if ref != nil {
- if err := s.movePurchase(ctx, p, p.State, func(p *DomainPurchase) { p.Reason = ref.Msg }); err != nil {
+ capacityRefused := ref.haCapacityRetryAfter > 0
+ if err := s.movePurchase(ctx, p, p.State, func(p *DomainPurchase) {
+ p.Reason = ref.Msg
+ if !capacityRefused {
+ p.Attempts++
+ }
+ }); err != nil {
return err
}
- if p.Attempts == 10 {
+ if !capacityRefused && p.Attempts == 10 {
s.purchaseAlert(ctx, acct, p.Domain, p.ID, p.Reason)
}
return nil
}
}
- return s.movePurchase(ctx, p, PurchaseDone, func(p *DomainPurchase) { p.Reason = "" })
+ return s.movePurchase(ctx, p, PurchaseDone, func(p *DomainPurchase) { p.Reason = ""; p.Attempts++ })
}
return nil
}
diff --git a/internal/console/domainbuy_capacity_test.go b/internal/console/domainbuy_capacity_test.go
new file mode 100644
index 000000000..a6b148fa6
--- /dev/null
+++ b/internal/console/domainbuy_capacity_test.go
@@ -0,0 +1,94 @@
+package console
+
+import (
+ "context"
+ "reflect"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+func TestDomainPurchaseHACapacityRetries(t *testing.T) {
+ for _, evidence := range []string{"zero", "unknown"} {
+ t.Run(evidence, func(t *testing.T) {
+ f := newPurchaseFixture(t)
+ pages := pagesTo(t)
+ purchasePages := 0
+ previousPage := pageDomainPurchase
+ pageDomainPurchase = func(context.Context, string, string, string) error {
+ purchasePages++
+ return nil
+ }
+ t.Cleanup(func() { pageDomainPurchase = previousPage })
+ ctx := context.Background()
+ p := f.start(t)
+ f.authorise(t, p)
+ p = f.until(t, p.ID, PurchaseCaptured)
+ f.srv.cfg.Registry = f.regPath
+ f.srv.cfg.HomeRegion = "ie"
+ f.srv.cfg.HARegions = []string{"ie"}
+ m := release.Manifest{Schema: 1, App: p.App, Version: "v1", Kind: "binary", BuiltAt: "2026-07-03T10:00:00Z", Artifacts: map[string]release.Artifact{"linux-amd64": {File: p.App}}}
+ if err := release.Ship(ctx, f.rel, f.acct.Sqid, m, map[string][]byte{"linux-amd64": []byte("binary v1")}); err != nil {
+ t.Fatal(err)
+ }
+ if err := release.Promote(ctx, f.rel, f.priv, f.acct.Sqid, p.App, "edge", "v1"); err != nil {
+ t.Fatal(err)
+ }
+ createCapacityEvidence(t, f.srv, evidence, nil)
+ control := &haCreateStore{Store: f.srv.cfg.Releases}
+ f.srv.cfg.Releases = control
+ local := capacityLocalWrites(t, f.consoleFixture)
+ before := bucketState(t, f.rel)
+ wantReason := capacityUnknownIE
+ if evidence == "zero" {
+ wantReason = noCapacityRefusal("ie")
+ }
+ for _, attempts := range []int{0, 9, 10} {
+ if err := f.srv.movePurchase(ctx, p, p.State, func(p *DomainPurchase) { p.Attempts = attempts }); err != nil {
+ t.Fatal(err)
+ }
+ for pass := 0; pass < 3; pass++ {
+ if err := f.srv.domainPurchasePass(ctx); err != nil {
+ t.Fatal(err)
+ }
+ p = f.read(t, p.ID)
+ if p.State != PurchaseCaptured || p.Reason != wantReason || p.Attempts != attempts || purchasePages != 0 {
+ t.Errorf("attempts=%d pass=%d: state=%s reason=%q attempts=%d purchase pages=%d", attempts, pass, p.State, p.Reason, p.Attempts, purchasePages)
+ }
+ if writes, _ := control.counts(); writes != 0 {
+ t.Fatalf("capacity refusal attempted %d bucket writes", writes)
+ }
+ local()
+ if after := bucketState(t, f.rel); !reflect.DeepEqual(before, after) {
+ t.Fatal("capacity refusal changed records or claims")
+ }
+ }
+ }
+ if evidence == "zero" {
+ expectPages(t, pages, noRoomSubject("ie"))
+ } else {
+ expectPages(t, pages)
+ }
+ createCapacityEvidence(t, f.srv, "allow", nil)
+ if err := f.srv.domainPurchasePass(ctx); err != nil {
+ t.Fatal(err)
+ }
+ p = f.read(t, p.ID)
+ if p.State != PurchaseDone || p.Reason != "" || p.Attempts != 11 || purchasePages != 0 {
+ t.Fatalf("positive evidence: %+v purchase pages=%d", p, purchasePages)
+ }
+ for _, host := range []string{p.Domain, "www." + p.Domain} {
+ claim, err := domains.GetClaim(ctx, f.rel, host)
+ if err != nil || claim.Account != f.acct.Sqid || claim.App != p.App {
+ t.Fatalf("claim %s: %+v %v", host, claim, err)
+ }
+ record, err := provision.GetRecord(ctx, f.rel, f.acct.Sqid, p.App, host)
+ if err != nil || record.Kind != "static" {
+ t.Fatalf("record %s: %+v %v", host, record, err)
+ }
+ }
+ })
+ }
+}
diff --git a/internal/console/domainbuy_copy.go b/internal/console/domainbuy_copy.go
index ea7dafbb0..a7e8e3de6 100644
--- a/internal/console/domainbuy_copy.go
+++ b/internal/console/domainbuy_copy.go
@@ -82,11 +82,11 @@ func domainBuyErrorRefusal(err error) *doorRefusal {
case errors.Is(err, domainreg.ErrNotAvailable), errors.Is(err, registrar.ErrUnavailable):
return claimRefusal("", domains.ErrHostUnavailable)
case errors.Is(err, domainreg.ErrNotRegistrable):
- return &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["nameError"]}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["nameError"]}
case errors.Is(err, domainreg.ErrTLDNotOffered):
- return &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["notOffered"]}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["notOffered"]}
case errors.Is(err, domainreg.ErrPremium):
- return &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["premium"]}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["premium"]}
case errors.Is(err, domainreg.ErrCostAboveCeiling), errors.Is(err, registrar.ErrRefused), errors.Is(err, registrar.ErrIndeterminate):
log.Printf("console: domain buy refused: %v", err)
default:
@@ -106,7 +106,7 @@ var domainPurchaseCopy = struct {
}
func domainBuyStateRefusal(key string, status int) *doorRefusal {
- return &doorRefusal{status, domainBuyCopy[key]}
+ return &doorRefusal{Status: status, Msg: domainBuyCopy[key]}
}
func (s *Server) domainBuyRegistrarRefusal(ctx context.Context, acct *Account, name string, err error) *doorRefusal {
diff --git a/internal/console/domaincatchall.go b/internal/console/domaincatchall.go
index dd43c3609..bb243c364 100644
--- a/internal/console/domaincatchall.go
+++ b/internal/console/domaincatchall.go
@@ -86,7 +86,7 @@ func (s *Server) attachInstanceCatchall(ctx context.Context, acct *Account, app,
// Host-claim consoles: catch-all claims are written only by the legacy
// capability path, an intentionally unsupported operation here.
if s.cfg.HostClaim {
- return false, &doorRefusal{http.StatusConflict, claimRefusalText(errClaimAliasCapabilitiesUnsupported)}
+ return false, &doorRefusal{Status: http.StatusConflict, Msg: claimRefusalText(errClaimAliasCapabilitiesUnsupported)}
}
if ref := s.bucketRefusal(); ref != nil {
return false, ref
@@ -95,7 +95,7 @@ func (s *Server) attachInstanceCatchall(ctx context.Context, acct *Account, app,
return false, &doorRefusal{Status: status, Msg: msg}
}
if s.catchallParentRefused(parent, acct.Sqid) {
- return false, &doorRefusal{http.StatusBadRequest, "that hostname is platform-managed"}
+ return false, &doorRefusal{Status: http.StatusBadRequest, Msg: "that hostname is platform-managed"}
}
// Plans 3a: a catch-all is a custom domain too.
if ref := s.customDomainRefusal(acct, parent); ref != nil {
@@ -114,7 +114,7 @@ func (s *Server) attachInstanceCatchall(ctx context.Context, acct *Account, app,
// AttachInstanceCatchall judges the parent again under its own write.
switch apex, err := domains.GetClaim(ctx, s.cfg.Releases, parent); {
case errors.Is(err, os.ErrNotExist), err == nil && (apex.Account != acct.Sqid || apex.Pending):
- return false, &doorRefusal{http.StatusConflict, catchallParentMsg(parent)}
+ return false, &doorRefusal{Status: http.StatusConflict, Msg: catchallParentMsg(parent)}
case err != nil:
return false, claimRefusal(domains.InstanceCatchallHost(parent), err)
}
@@ -122,7 +122,7 @@ func (s *Server) attachInstanceCatchall(ctx context.Context, acct *Account, app,
defer s.regionalMu.Unlock()
if ref := s.regionalDescendantRefusal(ctx, parent); ref != nil {
if ref.Status == http.StatusConflict {
- ref = &doorRefusal{http.StatusConflict, instanceCatchallOverRegionalMsg}
+ ref = &doorRefusal{Status: http.StatusConflict, Msg: instanceCatchallOverRegionalMsg}
}
return false, ref
}
@@ -130,10 +130,10 @@ func (s *Server) attachInstanceCatchall(ctx context.Context, acct *Account, app,
time.Now().UTC().Format(time.RFC3339), principal)
switch {
case errors.Is(err, domains.ErrParentNotHeld):
- return false, &doorRefusal{http.StatusConflict, catchallParentMsg(parent)}
+ return false, &doorRefusal{Status: http.StatusConflict, Msg: catchallParentMsg(parent)}
case errors.Is(err, domains.ErrRegionalClaim):
// Before claimRefusal, which answers the sentinel with RD-26.
- return false, &doorRefusal{http.StatusConflict, instanceCatchallOverRegionalMsg}
+ return false, &doorRefusal{Status: http.StatusConflict, Msg: instanceCatchallOverRegionalMsg}
case err != nil:
return false, claimRefusal(domains.InstanceCatchallHost(parent), err)
}
@@ -183,7 +183,7 @@ func (s *Server) heldElsewhere(ctx context.Context, host, sqid, app string) *doo
held, err := s.catchallInstanceName(ctx, host, sqid, app)
if err != nil {
log.Printf("console: attach %s: instance catch-all check: %v", host, err)
- return &doorRefusal{http.StatusBadGateway, "could not check the hostname — try again"}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: "could not check the hostname — try again"}
}
if held {
return claimRefusal(host, domains.ErrHostUnavailable)
@@ -284,11 +284,11 @@ func (s *Server) catchallAppReady(ctx context.Context, acct *Account, app string
_, err := provision.GetManifest(ctx, s.cfg.Releases, acct.Sqid, app)
switch {
case errors.Is(err, os.ErrNotExist):
- return &doorRefusal{http.StatusConflict,
- app + " has no instances — enable them first (carlos instances enable), then attach the catch-all"}
+ return &doorRefusal{Status: http.StatusConflict,
+ Msg: app + " has no instances — enable them first (carlos instances enable), then attach the catch-all"}
case err != nil:
log.Printf("console: instance catch-all %s/%s: manifest: %v", acct.Sqid, app, err)
- return &doorRefusal{http.StatusBadGateway, "could not read this app's instance settings — try again"}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: "could not read this app's instance settings — try again"}
}
return nil
}
diff --git a/internal/console/egressfleet.go b/internal/console/egressfleet.go
index 6fed10da6..abfe747bb 100644
--- a/internal/console/egressfleet.go
+++ b/internal/console/egressfleet.go
@@ -60,24 +60,24 @@ func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notC
return []string{}, nil
}
if s.cfg.Releases == nil {
- return nil, &doorRefusal{http.StatusServiceUnavailable, egressFleetListMsg}
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetListMsg}
}
inv, err := edgesfile.ReadAddrsCached(ctx, s.cfg.Releases, &s.egressAddrs)
if err != nil {
s.policyLogf("console: egress grant check: list %s: %v", edgesfile.Prefix, err)
- return nil, &doorRefusal{http.StatusServiceUnavailable, egressFleetListMsg}
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetListMsg}
}
for _, a := range added {
if box, ok := inv.Holder(a); ok {
- return nil, &doorRefusal{http.StatusConflict, fmt.Sprintf(egressFleetHeldMsg, a, box)}
+ return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetHeldMsg, a, box)}
}
}
if len(inv.Unreadable) > 0 {
s.policyLogf("console: egress grant check: unreadable edges files: %s", strings.Join(inv.Unreadable, ", "))
- return nil, &doorRefusal{http.StatusServiceUnavailable, fmt.Sprintf(egressFleetUnreadableMsg, edgesKeyBox(inv.Unreadable[0]))}
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: fmt.Sprintf(egressFleetUnreadableMsg, edgesKeyBox(inv.Unreadable[0]))}
}
if len(inv.Missing) > 0 {
- return nil, &doorRefusal{http.StatusConflict, fmt.Sprintf(egressFleetOlderBoxMsg, inv.Missing[0])}
+ return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetOlderBoxMsg, inv.Missing[0])}
}
// Not checked: live boxes with no file. A partial box list would name
@@ -85,7 +85,7 @@ func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notC
boxes, partial, err := s.systemBoxes(ctx, false)
if err != nil || partial {
s.policyLogf("console: egress grant check: boxes (partial %t): %v", partial, err)
- return nil, &doorRefusal{http.StatusServiceUnavailable, egressFleetBoxesMsg}
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetBoxesMsg}
}
published := make(map[string]bool, len(inv.Boxes))
for b := range inv.Boxes {
diff --git a/internal/console/fleetfloor.go b/internal/console/fleetfloor.go
index 32293b8d9..0f56dd6ff 100644
--- a/internal/console/fleetfloor.go
+++ b/internal/console/fleetfloor.go
@@ -181,7 +181,7 @@ func (s *Server) fleetCreateFloorRefusal(ctx context.Context) *doorRefusal {
keys, err := s.cfg.Releases.List(ctx, prefix)
if err != nil {
log.Printf("console: fleet create barrier: list %s: %v", prefix, err)
- return &doorRefusal{http.StatusServiceUnavailable, consoleFleetCreateUnreadable}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: consoleFleetCreateUnreadable}
}
var channels []string
for _, key := range keys {
@@ -198,13 +198,13 @@ func (s *Server) fleetCreateFloorRefusal(ctx context.Context) *doorRefusal {
}
if err != nil {
log.Printf("console: fleet create barrier: system pointer %s: %v", ch, err)
- return &doorRefusal{http.StatusServiceUnavailable, consoleFleetCreateUnreadable}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: consoleFleetCreateUnreadable}
}
if p.AllowBelowFleetForwardFloor {
continue
}
if v, ok := release.ParseReleaseVersion(p.Current.Version); !ok || v.Compare(release.FleetForwardFloor) < 0 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(consoleFleetCreateFloorRefusal, ch, p.Current.Version, floor, floor)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(consoleFleetCreateFloorRefusal, ch, p.Current.Version, floor, floor)}
}
}
return nil
diff --git a/internal/console/hacreate.go b/internal/console/hacreate.go
index dd6215e09..5307e77e4 100644
--- a/internal/console/hacreate.go
+++ b/internal/console/hacreate.go
@@ -18,7 +18,7 @@ func (s *Server) haCreateShapeRefusal(rec provision.Record) *doorRefusal {
return demoDataRefusal()
}
if s.haRegion(rec.Region) && rec.KindOrDefault() == "instance" && len(rec.AddrsOrDefault()) == 0 && rec.Runtime == "" && !rec.HibernateOrDefault() {
- return &doorRefusal{http.StatusBadRequest, fmt.Sprintf("%s has high availability turned on. binary socket instances must allow hibernation. resident rootfs instances are still allowed.", s.offlineName(rec.Region))}
+ return &doorRefusal{Status: http.StatusBadRequest, Msg: fmt.Sprintf("%s has high availability turned on. binary socket instances must allow hibernation. resident rootfs instances are still allowed.", s.offlineName(rec.Region))}
}
return nil
}
diff --git a/internal/console/hacreate_test.go b/internal/console/hacreate_test.go
index 5a8ea18e1..cbdf4c8a4 100644
--- a/internal/console/hacreate_test.go
+++ b/internal/console/hacreate_test.go
@@ -636,7 +636,7 @@ func TestHACreateExistenceReadBudget(t *testing.T) {
s := &Server{cfg: Config{HomeRegion: "ie"}}
reads := 0
c := leftoverCreate{HAData: true, host: "shop.example.com", region: region,
- duplicate: doorRefusal{409, "duplicate"}, readFailed: doorRefusal{502, "read failure"},
+ duplicate: doorRefusal{Status: 409, Msg: "duplicate"}, readFailed: doorRefusal{Status: 502, Msg: "read failure"},
exists: func(context.Context) (bool, error) {
reads++
if result == "read-error" {
diff --git a/internal/console/hacreatecapacity_test.go b/internal/console/hacreatecapacity_test.go
index 07386f7dd..2bf99d825 100644
--- a/internal/console/hacreatecapacity_test.go
+++ b/internal/console/hacreatecapacity_test.go
@@ -214,6 +214,51 @@ func TestHACreateCapacityDoors(t *testing.T) {
}
}
+func TestHACreateCapacityRetryAfterUsesTypedMarker(t *testing.T) {
+ for _, evidence := range []string{"zero", "unknown", "missing-pools"} {
+ t.Run(evidence, func(t *testing.T) {
+ pages := pagesTo(t)
+ f := capacityFixture(t, "plain")
+ pool := ""
+ var edit func(map[string]any)
+ if evidence == "missing-pools" {
+ pool = "hapair"
+ edit = func(m map[string]any) { delete(m, "named_pools") }
+ }
+ createCapacityEvidence(t, f.fx.srv, evidence, edit)
+ ref := f.fx.srv.requireHACreateCapacity(context.Background(), "", pool)
+ if ref == nil || ref.Status != http.StatusServiceUnavailable || ref.haCapacityRetryAfter != 60 {
+ t.Fatalf("capacity refusal: %+v", ref)
+ }
+ want := capacityUnknownIE
+ if evidence == "zero" {
+ want = noCapacityRefusal("ie")
+ } else if evidence == "missing-pools" {
+ want = fmt.Sprintf(capacityPoolIE, pool)
+ }
+ if ref.Msg != want {
+ t.Fatalf("refusal=%q, want %q", ref.Msg, want)
+ }
+ ref.Msg = "changed test wording"
+ rec := httptest.NewRecorder()
+ setNoCapacityRetryAfter(rec, ref)
+ if got := rec.Header().Get("Retry-After"); got != "60" {
+ t.Fatalf("typed refusal Retry-After=%q", got)
+ }
+ if evidence != "zero" {
+ rec = httptest.NewRecorder()
+ setNoCapacityRetryAfter(rec, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: want})
+ if got := rec.Header().Get("Retry-After"); got != "" {
+ t.Fatalf("unmarked wording set Retry-After=%q", got)
+ }
+ expectPages(t, pages)
+ } else {
+ expectPages(t, pages, noRoomSubject("ie"))
+ }
+ })
+ }
+}
+
// SQLite triggers count attempts even if a later statement restores the row.
// Authentication bookkeeping is outside the protected create state.
func capacityLocalWrites(t *testing.T, fx *consoleFixture) func() {
diff --git a/internal/console/hostsused.go b/internal/console/hostsused.go
index 5b5897a87..1cf0ca13c 100644
--- a/internal/console/hostsused.go
+++ b/internal/console/hostsused.go
@@ -199,19 +199,19 @@ func (s *Server) hostsTargetRefusal(ctx context.Context, region string) *doorRef
st, err := s.hostsState(ctx)
if err != nil {
log.Printf("console: hosts used: read the mode to place a create on %q: %v", region, err)
- return &doorRefusal{http.StatusServiceUnavailable, msgHostsInvalidated}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostsInvalidated}
}
if st.Mode != provision.HostsModeActive {
return nil
}
if fleet, ok := registry.FleetPlacement(region); ok {
if slices.Contains(st.Closed, "fleet:"+fleet) || !slices.Contains(st.Examined, "fleet:"+fleet) {
- return &doorRefusal{http.StatusConflict, msgHostsTargetUnexamined("fleet " + fleet)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgHostsTargetUnexamined("fleet " + fleet)}
}
return nil
}
if !regionExamined(st, region) {
- return &doorRefusal{http.StatusConflict, msgHostsTargetUnexamined(s.placeOf(region, s.candsOrHome(ctx)))}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgHostsTargetUnexamined(s.placeOf(region, s.candsOrHome(ctx)))}
}
return nil
}
@@ -245,7 +245,7 @@ func (s *Server) hostsCoverageRefusal(ctx context.Context, region string) *doorR
}
if err != nil || fl == nil {
log.Printf("console: hosts used: read fleet %s's targets: %v", fleet, err)
- return &doorRefusal{http.StatusServiceUnavailable, msgHostsInvalidated}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostsInvalidated}
}
} else {
if s.cfg.Releases == nil {
@@ -254,7 +254,7 @@ func (s *Server) hostsCoverageRefusal(ctx context.Context, region string) *doorR
snap, err := readEdgesSnapshot(ctx, s.cfg.Releases)
if err != nil || !snap.Complete {
log.Printf("console: hosts used: read the edges files to check region %q's targets: %v (complete %v)", region, err, snap.Complete)
- return &doorRefusal{http.StatusServiceUnavailable, msgHostsInvalidated}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostsInvalidated}
}
now, recorded = rosterRegions(snap)["region:"+region], st.RegionTargets
place = snapshotPlaceName(snap, region, s.homeRegionOut(region))
@@ -265,7 +265,7 @@ func (s *Server) hostsCoverageRefusal(ctx context.Context, region string) *doorR
place = "the home region"
}
log.Printf("console: hosts used: %s on %q was not scanned when the history was completed", t, region)
- return &doorRefusal{http.StatusConflict, msgHostsTargetUnexamined(place)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgHostsTargetUnexamined(place)}
}
}
return nil
@@ -350,7 +350,7 @@ func (s *Server) addFleetBoxRecorded(ctx context.Context, reg consoleRegistry, f
defer s.hosts.mu.Unlock()
if err := s.loadHostsLocked(ctx); err != nil {
log.Printf("console: hosts used: read the mode to add a box to fleet %s: %v", fl.Name, err)
- return &doorRefusal{http.StatusServiceUnavailable, msgFleetBoxNotAdded}, nil
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgFleetBoxNotAdded}, nil
}
st, key := s.hosts.state, "fleet:"+fl.Name
if st.Mode != provision.HostsModeActive {
@@ -359,14 +359,14 @@ func (s *Server) addFleetBoxRecorded(ctx context.Context, reg consoleRegistry, f
boxes, err := reg.ListFleetBoxes(fl.Name)
if err != nil {
log.Printf("console: hosts used: list fleet %s's boxes: %v", fl.Name, err)
- return &doorRefusal{http.StatusServiceUnavailable, msgFleetBoxNotAdded}, nil
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgFleetBoxNotAdded}, nil
}
active := slices.ContainsFunc(boxes, func(b registry.FleetBox) bool { return b.Label == box.Label && b.Status == "active" })
if slices.Contains(st.Examined, key) || slices.Contains(st.Closed, key) {
if !slices.Contains(st.Closed, key) && st.FirstBox[key] == box.Label && !active {
return nil, reg.AddFleetBox(box)
}
- return &doorRefusal{http.StatusConflict, msgFleetInventoried(fl.Name)}, nil
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgFleetInventoried(fl.Name)}, nil
}
for _, c := range st.Closed {
if ts, ok := st.FleetTargets[c]; !ok || (fl.Bucket != "" && slices.Contains(ts, "bucket:"+fl.Bucket)) {
@@ -380,7 +380,7 @@ func (s *Server) addFleetBoxRecorded(ctx context.Context, reg consoleRegistry, f
targets, err := rosterFleet(reg, fl)
if err != nil {
log.Printf("console: hosts used: record new fleet %s: read its targets: %v", fl.Name, err)
- return &doorRefusal{http.StatusServiceUnavailable, msgFleetBoxNotAdded}, nil
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgFleetBoxNotAdded}, nil
}
next := st
next.Examined = sortedUnique(append(slices.Clone(st.Examined), key))
@@ -399,7 +399,7 @@ func (s *Server) addFleetBoxRecorded(ctx context.Context, reg consoleRegistry, f
// It may land yet: read the store next time, never this guess.
log.Printf("console: hosts used: record new fleet %s: write the mode: %v (no box added; the next caller reads the mode again)", fl.Name, err)
s.hosts.state, s.hosts.etag = provision.HostsState{}, ""
- return &doorRefusal{http.StatusServiceUnavailable, msgFleetBoxNotAdded}, nil
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgFleetBoxNotAdded}, nil
}
s.hosts.state, s.hosts.etag = next, etag
log.Printf("console: hosts used: fleet %s recorded at its first box %s, targets %v", fl.Name, box.Label, next.FleetTargets[key])
@@ -414,12 +414,12 @@ func (s *Server) admitDataCreate(ctx context.Context, host string) *doorRefusal
defer s.hosts.mu.Unlock()
if err := s.loadHostsLocked(ctx); err != nil {
log.Printf("console: hosts used: read the mode to admit a create of %s: %v", host, err)
- return &doorRefusal{http.StatusServiceUnavailable, msgHostUnchecked(host)}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostUnchecked(host)}
}
switch {
case s.hosts.state.Mode == provision.HostsModeInvalidated,
s.hosts.state.Mode == provision.HostsModeActive && !s.hosts.verified:
- return &doorRefusal{http.StatusServiceUnavailable, msgHostsInvalidated}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostsInvalidated}
}
return nil
}
@@ -576,10 +576,10 @@ func (s *Server) markHost(ctx context.Context, u provision.HostUse) (markResult,
mode, err := s.hostsMode(ctx)
if err != nil {
log.Printf("console: hosts used: read the mode for %s: %v", u.Host, err)
- return 0, &doorRefusal{http.StatusServiceUnavailable, msgHostUnchecked(u.Host)}
+ return 0, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostUnchecked(u.Host)}
}
if mode == provision.HostsModeInvalidated {
- return 0, &doorRefusal{http.StatusServiceUnavailable, msgHostsInvalidated}
+ return 0, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostsInvalidated}
}
if u.At.IsZero() {
u.At = time.Now().UTC()
@@ -587,7 +587,7 @@ func (s *Server) markHost(ctx context.Context, u provision.HostUse) (markResult,
fresh, err := provision.MarkHostUsed(ctx, s.cfg.Releases, u)
if err != nil {
log.Printf("console: hosts used: mark %s: %v", u.Host, err)
- return 0, &doorRefusal{http.StatusServiceUnavailable, msgHostUnchecked(u.Host)}
+ return 0, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostUnchecked(u.Host)}
}
if fresh || mode != provision.HostsModeActive {
return markPass, nil
@@ -605,7 +605,7 @@ func (s *Server) markForCreate(ctx context.Context, u provision.HostUse) *doorRe
return ref
}
if res == markConflict {
- return &doorRefusal{http.StatusConflict, msgHostUsed(u.Host)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgHostUsed(u.Host)}
}
return nil
}
@@ -629,10 +629,10 @@ func (s *Server) markBeforeCreate(ctx context.Context, u provision.HostUse, key
case err == nil:
return release.ErrCASConflict
case errors.Is(err, os.ErrNotExist):
- return &hostsUsedError{doorRefusal{http.StatusConflict, msgHostUsed(u.Host)}}
+ return &hostsUsedError{doorRefusal{Status: http.StatusConflict, Msg: msgHostUsed(u.Host)}}
}
log.Printf("console: hosts used: read %s after a conflicting mark: %v", key, err)
- return &hostsUsedError{doorRefusal{http.StatusServiceUnavailable, msgHostUnchecked(u.Host)}}
+ return &hostsUsedError{doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgHostUnchecked(u.Host)}}
}
// recordUse is the mark a data-kind instance record's create writes.
diff --git a/internal/console/lifetimes.go b/internal/console/lifetimes.go
index 08d62a173..d6e628068 100644
--- a/internal/console/lifetimes.go
+++ b/internal/console/lifetimes.go
@@ -134,20 +134,20 @@ func lifetimeCreateRefusal(host string, err error, pendingMsg string) (*doorRefu
var regional *regionalHostError
switch {
case errors.As(err, &regional):
- return &doorRefusal{http.StatusConflict, claimHeldSentence(host, regional.hold)}, true
+ return &doorRefusal{Status: http.StatusConflict, Msg: claimHeldSentence(host, regional.hold)}, true
case errors.As(err, &used):
// The hostname history's refusal (hostsused.go), lifetimes on or off.
return &used.ref, true
case errors.As(err, &held):
- return &doorRefusal{http.StatusConflict, hostHeldSentence(host, held.Hold)}, true
+ return &doorRefusal{Status: http.StatusConflict, Msg: hostHeldSentence(host, held.Hold)}, true
case errors.Is(err, errLifetimeSettling):
- return &doorRefusal{http.StatusConflict, msgLifetimeSettling}, true
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgLifetimeSettling}, true
case errors.Is(err, errLifetimePending):
- return &doorRefusal{http.StatusBadGateway, pendingMsg}, true
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: pendingMsg}, true
case errors.As(err, &app):
- return &doorRefusal{app.Status, app.Msg}, true
+ return &doorRefusal{Status: app.Status, Msg: app.Msg}, true
case errors.Is(err, provision.ErrLifetimeExhausted):
- return &doorRefusal{http.StatusInternalServerError, msgLifetimeExhausted}, true
+ return &doorRefusal{Status: http.StatusInternalServerError, Msg: msgLifetimeExhausted}, true
}
return nil, false
}
diff --git a/internal/console/lifetimes_floor.go b/internal/console/lifetimes_floor.go
index e871b86d7..da5504d3e 100644
--- a/internal/console/lifetimes_floor.go
+++ b/internal/console/lifetimes_floor.go
@@ -79,13 +79,13 @@ func (s *Server) lifetimesBoxFloor(ctx context.Context) *doorRefusal {
snap, err := readEdgesSnapshot(ctx, s.cfg.Releases)
if err != nil || !snap.Complete {
log.Printf("console: lifetimes: the box floor: the edges files are not complete evidence (error %v)", err)
- return &doorRefusal{http.StatusConflict, msgLifetimesFleetUnread}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgLifetimesFleetUnread}
}
files := snap.Files
sort.Slice(files, func(i, j int) bool { return files[i].Box < files[j].Box })
for _, f := range files {
if !slices.Contains(f.Capabilities, capLifetimes1) {
- return &doorRefusal{http.StatusConflict, msgLifetimesBoxBelowFloor(f.Box)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgLifetimesBoxBelowFloor(f.Box)}
}
}
boxes, complete, err := status.LoadBoxesComplete(ctx, s.cfg.Releases)
@@ -105,9 +105,9 @@ func (s *Server) lifetimesBoxFloor(ctx context.Context) *doorRefusal {
switch {
case ok && dup[f.Box]:
log.Printf("console: lifetimes: the box floor: box %q has more than one status report with its label", f.Box)
- return &doorRefusal{http.StatusConflict, msgLifetimesBoxAmbiguous(f.Box)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgLifetimesBoxAmbiguous(f.Box)}
case !ok || !lifetimesBoxReportFresh(at, now):
- return &doorRefusal{http.StatusConflict, msgLifetimesBoxSilent(f.Box)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgLifetimesBoxSilent(f.Box)}
}
}
return nil
diff --git a/internal/console/lifetimes_retire.go b/internal/console/lifetimes_retire.go
index e6f5637a2..8d9dcf653 100644
--- a/internal/console/lifetimes_retire.go
+++ b/internal/console/lifetimes_retire.go
@@ -380,11 +380,11 @@ func (s *Server) recoverRetirementLocked(ctx context.Context, r Retirement) {
func lifetimeRetireRefusal(err error, settlingMsg, pendingMsg string, pendingStatus int) (*doorRefusal, bool) {
switch {
case errors.Is(err, errLifetimeSettling):
- return &doorRefusal{http.StatusConflict, settlingMsg}, true
+ return &doorRefusal{Status: http.StatusConflict, Msg: settlingMsg}, true
case errors.Is(err, errRetireRefused):
- return &doorRefusal{http.StatusConflict, msgRetireRefused}, true
+ return &doorRefusal{Status: http.StatusConflict, Msg: msgRetireRefused}, true
case errors.Is(err, errLifetimePending):
- return &doorRefusal{pendingStatus, pendingMsg}, true
+ return &doorRefusal{Status: pendingStatus, Msg: pendingMsg}, true
}
return nil, false
}
diff --git a/internal/console/nocapacity.go b/internal/console/nocapacity.go
index 0a3379b54..b8f57385b 100644
--- a/internal/console/nocapacity.go
+++ b/internal/console/nocapacity.go
@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"net/http"
+ "strconv"
"strings"
"sync"
"time"
@@ -57,13 +58,15 @@ func (s *Server) requireHACreateCapacity(ctx context.Context, region, pool strin
case HACapacityAllow:
return nil
case HACapacityCompleteZero:
- return claimResponseRefusal(s.noRoom(ctx, region))
+ ref := claimResponseRefusal(s.noRoom(ctx, region))
+ ref.haCapacityRetryAfter = 60
+ return ref
default:
msg := fmt.Sprintf(haCapacityUnknownRefusal, name)
if decision.MissingNamedPoolsOnly {
msg = fmt.Sprintf(haCapacityPoolRefusal, pool, name)
}
- return &doorRefusal{http.StatusServiceUnavailable, msg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msg, haCapacityRetryAfter: 60}
}
}
@@ -141,8 +144,9 @@ func isNoCapacityRefusal(ref *doorRefusal) bool {
// setNoCapacityRetryAfter stamps noCapacityRetryAfter on w when ref is the
// no-room or HA evidence refusal. Other refusals keep their existing headers.
func setNoCapacityRetryAfter(w http.ResponseWriter, ref *doorRefusal) {
- if isNoCapacityRefusal(ref) || (ref != nil && ref.Status == http.StatusServiceUnavailable &&
- (strings.HasPrefix(ref.Msg, "Capacity evidence for ") || strings.HasPrefix(ref.Msg, "Capacity for pool "))) {
+ if ref != nil && ref.haCapacityRetryAfter > 0 {
+ w.Header().Set("Retry-After", strconv.Itoa(ref.haCapacityRetryAfter))
+ } else if isNoCapacityRefusal(ref) {
w.Header().Set("Retry-After", noCapacityRetryAfter)
}
}
diff --git a/internal/console/nocapacity_test.go b/internal/console/nocapacity_test.go
index ff4007b8a..1d3370038 100644
--- a/internal/console/nocapacity_test.go
+++ b/internal/console/nocapacity_test.go
@@ -743,7 +743,7 @@ func TestNoRoomCarriesRetryAfterAMinute(t *testing.T) {
t.Fatalf("unavailable refusal %d Retry-After %q, want 503 and 2", rec.Code, rec.Header().Get("Retry-After"))
}
rec = httptest.NewRecorder()
- cx.srv.renderDoorRefusal(rec, req, &doorRefusal{http.StatusServiceUnavailable, claimResponseUnavailable})
+ cx.srv.renderDoorRefusal(rec, req, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: claimResponseUnavailable})
if rec.Header().Get("Retry-After") != "" {
t.Fatalf("browser unavailable refusal Retry-After %q, want none (main's)", rec.Header().Get("Retry-After"))
}
diff --git a/internal/console/plancaps.go b/internal/console/plancaps.go
index 412745eee..5b780901b 100644
--- a/internal/console/plancaps.go
+++ b/internal/console/plancaps.go
@@ -256,9 +256,9 @@ func (s *Server) customDomainRefusal(acct *Account, host string) *doorRefusal {
}
if err := s.checkCustomDomains(acct); err != nil {
if isPlanCap(err) {
- return &doorRefusal{http.StatusConflict, err.Error()}
+ return &doorRefusal{Status: http.StatusConflict, Msg: err.Error()}
}
- return &doorRefusal{http.StatusBadGateway, planCheckFailedCopy}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: planCheckFailedCopy}
}
return nil
}
diff --git a/internal/console/policylease.go b/internal/console/policylease.go
index 73d036ee2..87d677d82 100644
--- a/internal/console/policylease.go
+++ b/internal/console/policylease.go
@@ -145,9 +145,9 @@ func (s *Server) policyWriter(ctx context.Context) (policyHolding, *doorRefusal)
return policyHolding{n: 1, sole: true}, nil
}
if s.cfg.PolicyLease == nil {
- return policyHolding{}, &doorRefusal{http.StatusServiceUnavailable, policyLeaseMissingMsg}
+ return policyHolding{}, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyLeaseMissingMsg}
}
- unavailable := &doorRefusal{http.StatusServiceUnavailable, policyLeaseUnavailableMsg}
+ unavailable := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyLeaseUnavailableMsg}
s.policyLeaseMu.Lock()
defer s.policyLeaseMu.Unlock()
@@ -209,11 +209,11 @@ func (s *Server) policyWriter(ctx context.Context) (policyHolding, *doorRefusal)
until := held.ExpiresAt.UTC().Format(time.RFC3339)
if strings.TrimSpace(held.Owner) == "" {
// A lock with no owner: name the expiry alone, never "()".
- return policyHolding{}, &doorRefusal{http.StatusServiceUnavailable,
- fmt.Sprintf(policyLeaseHeldNoOwnerMsg, until)}
+ return policyHolding{}, &doorRefusal{Status: http.StatusServiceUnavailable,
+ Msg: fmt.Sprintf(policyLeaseHeldNoOwnerMsg, until)}
}
- return policyHolding{}, &doorRefusal{http.StatusServiceUnavailable,
- fmt.Sprintf(policyLeaseHeldMsg, held.Owner, until)}
+ return policyHolding{}, &doorRefusal{Status: http.StatusServiceUnavailable,
+ Msg: fmt.Sprintf(policyLeaseHeldMsg, held.Owner, until)}
}
s.policyLogf("console: policy writer lease: %v", err)
return policyHolding{}, unavailable
@@ -231,7 +231,7 @@ func (s *Server) policyAttempt(ctx context.Context, h policyHolding) (context.Co
if h.sole {
return ctx, func() {}, nil
}
- lost := &doorRefusal{http.StatusServiceUnavailable, policyLeaseLostMsg}
+ lost := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: policyLeaseLostMsg}
s.policyStateMu.Lock()
cur := s.policyCur
if cur == nil || cur.h.n != h.n || h.lease == nil {
diff --git a/internal/console/policysize.go b/internal/console/policysize.go
index e5cb79320..0588345f2 100644
--- a/internal/console/policysize.go
+++ b/internal/console/policysize.go
@@ -245,11 +245,11 @@ func (s *Server) sizeCapacityCheck(ctx context.Context, acct *Account, recs []pr
func sizeRefusal(boxes []sizeBox, complete bool, size cgroup.Size) *doorRefusal {
if sizeAboveStandard(size) {
if !complete {
- return &doorRefusal{http.StatusServiceUnavailable, sizeUnreadMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: sizeUnreadMsg}
}
for _, b := range boxes {
if b.TotalMiB == 0 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(sizeNoTotalMsg, b.Box)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(sizeNoTotalMsg, b.Box)}
}
}
}
@@ -260,7 +260,7 @@ func sizeRefusal(boxes []sizeBox, complete bool, size cgroup.Size) *doorRefusal
}
}
if smallest != nil && size.Limit.MemoryMax>>20 > smallest.TotalMiB/4 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(sizeQuarterMsg, size.Name, smallest.Box, smallest.TotalMiB)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(sizeQuarterMsg, size.Name, smallest.Box, smallest.TotalMiB)}
}
return nil
}
@@ -327,7 +327,7 @@ func (s *Server) policySizeCheck(ctx context.Context, acct *Account, app string,
for _, c := range checks {
recs, ok := s.policySizeRecords(ctx, acct, app, c.host)
if !ok && sizeAboveStandard(c.size) {
- return nil, &doorRefusal{http.StatusServiceUnavailable, sizeUnreadMsg}
+ return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: sizeUnreadMsg}
}
// An unread record set is checked against every box (recs nil):
// more boxes, never fewer.
diff --git a/internal/console/regionclaim.go b/internal/console/regionclaim.go
index 2bc8b4a98..92081e3f7 100644
--- a/internal/console/regionclaim.go
+++ b/internal/console/regionclaim.go
@@ -38,11 +38,11 @@ func (s *Server) validateExplicitRegion(ctx context.Context, raw string) (string
case "":
return code, nil
case "unknown":
- return "", &doorRefusal{http.StatusBadRequest, msgRegionUnknown(code, s.explicitChoices(gate))}
+ return "", &doorRefusal{Status: http.StatusBadRequest, Msg: msgRegionUnknown(code, s.explicitChoices(gate))}
case "not-armed":
- return "", &doorRefusal{http.StatusBadRequest, msgRegionNotArmed(code, s.explicitChoices(gate))}
+ return "", &doorRefusal{Status: http.StatusBadRequest, Msg: msgRegionNotArmed(code, s.explicitChoices(gate))}
}
- return "", &doorRefusal{http.StatusBadRequest, msgNoSecretsKey(code)}
+ return "", &doorRefusal{Status: http.StatusBadRequest, Msg: msgNoSecretsKey(code)}
}
// explicitGate is one read of what an explicit app region must pass.
diff --git a/internal/console/rootfs.go b/internal/console/rootfs.go
index d48cea423..e17dc4107 100644
--- a/internal/console/rootfs.go
+++ b/internal/console/rootfs.go
@@ -31,7 +31,7 @@ func (s *Server) statelessRuntimeRefusal(ctx context.Context, _ string, m *relea
if m == nil || !m.Stateless {
return nil
}
- ref := &doorRefusal{http.StatusConflict, fmt.Sprintf(statelessRuntimeFloorMsg, release.StatelessRuntimeFloor)}
+ ref := &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(statelessRuntimeFloorMsg, release.StatelessRuntimeFloor)}
if s.cfg.Releases == nil || s.cfg.Key == nil {
return ref
}
@@ -190,7 +190,7 @@ func (s *Server) readChannelHead(ctx context.Context, sqid, app, channel string)
// head answers alone; a nil one falls back to the history, fail closed.
func (s *Server) rootfsHeadFrom(ctx context.Context, sqid, app string, head *channelHead) (rootfsHead, *doorRefusal) {
if s.cfg.Releases == nil {
- return rootfsHead{}, &doorRefusal{http.StatusBadGateway, rootfsReleasesUnreadableMsg}
+ return rootfsHead{}, &doorRefusal{Status: http.StatusBadGateway, Msg: rootfsReleasesUnreadableMsg}
}
if head != nil {
if head.Manifest.Kind != release.KindRootfs {
@@ -202,7 +202,7 @@ func (s *Server) rootfsHeadFrom(ctx context.Context, sqid, app string, head *cha
switch {
case err != nil:
log.Printf("console: rootfs head %s/%s: read the app's kind: %v", sqid, app, err)
- return rootfsHead{}, &doorRefusal{http.StatusBadGateway, rootfsReleasesUnreadableMsg}
+ return rootfsHead{}, &doorRefusal{Status: http.StatusBadGateway, Msg: rootfsReleasesUnreadableMsg}
case info.Kind == "":
return rootfsHead{Unfixed: true}, nil
case info.Kind != release.KindRootfs:
@@ -221,7 +221,7 @@ func (s *Server) rootfsHeadFrom(ctx context.Context, sqid, app string, head *cha
// the place door does, 500 "could not check the fleet".
func (s *Server) rootfsPlacementRefusal(reg consoleRegistry, acct *Account, app, placed, pool string) *doorRefusal {
if pool != "" {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsPoolMsg, app)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsPoolMsg, app)}
}
if s.cfg.DeploymentSingleTenant {
return nil
@@ -229,10 +229,10 @@ func (s *Server) rootfsPlacementRefusal(reg consoleRegistry, acct *Account, app,
own, err := ownsFleet(reg, acct, placed)
if err != nil {
log.Printf("console: rootfs placement %s/%s: read fleet %q: %v", acct.Sqid, app, placed, err)
- return &doorRefusal{http.StatusInternalServerError, "could not check the fleet"}
+ return &doorRefusal{Status: http.StatusInternalServerError, Msg: "could not check the fleet"}
}
if !own {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsNotOwnBoxesMsg, app)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsNotOwnBoxesMsg, app)}
}
return nil
}
@@ -266,7 +266,7 @@ func (s *Server) rootfsPlacementRefusal(reg consoleRegistry, acct *Account, app,
// (LoadBoxesComplete: incomplete evidence is neither ready nor not
// ready): 503 C07.
func (s *Server) rootfsReadyRefusal(ctx context.Context, reg consoleRegistry, placed, region string) *doorRefusal {
- unreadable := &doorRefusal{http.StatusServiceUnavailable, rootfsReadyUnreadableMsg}
+ unreadable := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: rootfsReadyUnreadableMsg}
if s.cfg.Releases == nil {
return unreadable
}
@@ -319,9 +319,9 @@ func (s *Server) rootfsReadyRefusal(ctx context.Context, reg consoleRegistry, pl
return nil
}
if old != nil {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsFleetBelowFloorMsg, fleet, old.Label, old.Metrics.Release)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsFleetBelowFloorMsg, fleet, old.Label, old.Metrics.Release)}
}
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsFleetNotReadyMsg, fleet)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsFleetNotReadyMsg, fleet)}
}
hbs, complete, err := status.LoadBoxesComplete(ctx, s.cfg.Releases)
if err != nil || !complete {
@@ -340,9 +340,9 @@ func (s *Server) rootfsReadyRefusal(ctx context.Context, reg consoleRegistry, pl
}
name := s.rootfsRegionName(ctx, region)
if old != nil {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsRegionBelowFloorMsg, name, old.Label, old.Metrics.Release, name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsRegionBelowFloorMsg, name, old.Label, old.Metrics.Release, name)}
}
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsRegionNotReadyMsg, name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsRegionNotReadyMsg, name)}
}
// rootfsRegionName is a region as C06 names it: its place, the name the
@@ -394,9 +394,9 @@ func boxAtRootfsFloor(b status.Box) bool {
func (s *Server) rootfsCreateRefusal(ctx context.Context, reg consoleRegistry, acct *Account, app, placed, region, pool, role string, seeded bool, fleetActive *fleetView) *doorRefusal {
switch {
case seeded:
- return &doorRefusal{http.StatusUnprocessableEntity, fmt.Sprintf(rootfsSeededMsg, app)}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: fmt.Sprintf(rootfsSeededMsg, app)}
case role == "replica":
- return &doorRefusal{http.StatusUnprocessableEntity, fmt.Sprintf(rootfsReplicaMsg, app)}
+ return &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: fmt.Sprintf(rootfsReplicaMsg, app)}
}
if ref := s.rootfsPlacementRefusal(reg, acct, app, placed, pool); ref != nil {
return ref
@@ -419,7 +419,7 @@ func rootfsChosenBoxRefusal(placed string, v fleetView) *doorRefusal {
return nil
}
fleet, _ := registry.FleetPlacement(placed)
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsFleetNotReadyMsg, fleet)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsFleetNotReadyMsg, fleet)}
}
// The first-kind boundary (Astra R2 finding 2; Plan 4 row 3.2). The create
@@ -504,7 +504,7 @@ func (s *Server) firstKindRecheck(ctx context.Context, rec provision.Record) err
func (s *Server) firstRootfsShipRefusal(ctx context.Context, acct *Account, app string) *doorRefusal {
unchecked := func(what string, err error) *doorRefusal {
log.Printf("console: api ship %s/%s: count the instances made before the first release: %s: %v", acct.Sqid, app, what, err)
- return &doorRefusal{http.StatusServiceUnavailable, shipKindUnchecked}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: shipKindUnchecked}
}
recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app)
if err != nil {
@@ -533,7 +533,7 @@ func (s *Server) firstRootfsShipRefusal(ctx context.Context, acct *Account, app
return nil
}
hosts := slices.Sorted(maps.Keys(binary))
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(rootfsFirstShipMsg, app, len(hosts), hosts[0])}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(rootfsFirstShipMsg, app, len(hosts), hosts[0])}
}
// binaryInstance reports whether rec is an instance the platform starts
diff --git a/internal/console/seedfloor.go b/internal/console/seedfloor.go
index cd1977414..7e0c5cc00 100644
--- a/internal/console/seedfloor.go
+++ b/internal/console/seedfloor.go
@@ -48,17 +48,17 @@ func (s *Server) seedRegionReady(ctx context.Context, region string, oneBox bool
}
if err != nil {
log.Printf("console: seeds floor: %v", err)
- return &doorRefusal{http.StatusServiceUnavailable, "could not read the seeds floor. Try again."}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: "could not read the seeds floor. Try again."}
}
if floor == nil {
- return &doorRefusal{http.StatusConflict, "This deployment has no seeds floor yet. An operator publishes it with carlos system seeds-floor publish."}
+ return &doorRefusal{Status: http.StatusConflict, Msg: "This deployment has no seeds floor yet. An operator publishes it with carlos system seeds-floor publish."}
}
minProtocol := max(seeds.RequiredProtocol, floor.Min)
name := s.homeRegionOut(region)
if name == "" {
name = "the home region"
}
- unconfirmed := &doorRefusal{http.StatusServiceUnavailable, fmt.Sprintf("could not confirm every box in %s. Try again in a minute.", name)}
+ unconfirmed := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: fmt.Sprintf("could not confirm every box in %s. Try again in a minute.", name)}
snap, err := s.liveEdges(ctx)
if err != nil || !snap.EvidenceComplete() {
if err != nil {
@@ -86,10 +86,10 @@ func (s *Server) seedRegionReady(ctx context.Context, region string, oneBox bool
return unconfirmed
}
if oneBox && len(inRegion) > 1 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s has more than one box. An import needs a region with one box for now.", name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s has more than one box. An import needs a region with one box for now.", name)}
}
if len(below) > 0 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s in %s are below the seeds floor. Roll the platform there, then publish the seeds floor again.", boxList(below), name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s in %s are below the seeds floor. Roll the platform there, then publish the seeds floor again.", boxList(below), name)}
}
// The platform's own heartbeats, the set complete() vouched for. Never
// systemBoxes: it appends every customer fleet's heartbeats, and a fleet
@@ -141,10 +141,10 @@ func (s *Server) seedRegionReady(ctx context.Context, region string, oneBox bool
}
}
if len(flat) > 0 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s in %s do not run instances nested yet. A seeded instance needs every box there nested.", boxList(flat), name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s in %s do not run instances nested yet. A seeded instance needs every box there nested.", boxList(flat), name)}
}
if len(claimed) > 0 {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf("%s in %s run with claim control on. Seeded instances are not supported there yet.", boxList(claimed), name)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf("%s in %s run with claim control on. Seeded instances are not supported there yet.", boxList(claimed), name)}
}
return nil
}
@@ -153,7 +153,7 @@ func (s *Server) seedRegionReady(ctx context.Context, region string, oneBox bool
// control on. The --from door also gives it for a source whose claim could
// not be read, which seedRegionReady's own check makes unreachable today.
func seedClaimConsoleRefusal() *doorRefusal {
- return &doorRefusal{http.StatusConflict, "This console runs with claim control on. Seeded instances are not supported here yet."}
+ return &doorRefusal{Status: http.StatusConflict, Msg: "This console runs with claim control on. Seeded instances are not supported here yet."}
}
// boxList is the refusals' box names: sorted, comma-joined.
diff --git a/internal/console/seedscratch.go b/internal/console/seedscratch.go
index 6b2cdd453..03d2f17db 100644
--- a/internal/console/seedscratch.go
+++ b/internal/console/seedscratch.go
@@ -88,13 +88,13 @@ func (p *seedScratch) reserve(appKey string, bytes int64) (func(), *doorRefusal)
defer p.mu.Unlock()
acct, app, _ := strings.Cut(appKey, "/")
if p.perApp[appKey] {
- return nil, &doorRefusal{http.StatusTooManyRequests, fmt.Sprintf("another copy or upload is running for %s. Try again when it finishes.", app)}
+ return nil, &doorRefusal{Status: http.StatusTooManyRequests, Msg: fmt.Sprintf("another copy or upload is running for %s. Try again when it finishes.", app)}
}
if p.perAccount[acct] {
- return nil, &doorRefusal{http.StatusTooManyRequests, "another copy or upload is running in this account. try again when it finishes"}
+ return nil, &doorRefusal{Status: http.StatusTooManyRequests, Msg: "another copy or upload is running in this account. try again when it finishes"}
}
if p.running >= seedScratchAllApps {
- return nil, &doorRefusal{http.StatusTooManyRequests, "the console is already running two copies or uploads. Try again in a few minutes."}
+ return nil, &doorRefusal{Status: http.StatusTooManyRequests, Msg: "the console is already running two copies or uploads. Try again in a few minutes."}
}
if p.used == 0 {
p.readCapacity()
@@ -122,7 +122,7 @@ func (p *seedScratch) reserve(appKey string, bytes int64) (func(), *doorRefusal)
// seedScratchFull is the 507 the pool answers, and what a door answers
// when it cannot make its directory in the scratch.
func seedScratchFull() *doorRefusal {
- return &doorRefusal{http.StatusInsufficientStorage, "the console has no room for this right now. Try again later."}
+ return &doorRefusal{Status: http.StatusInsufficientStorage, Msg: "the console has no room for this right now. Try again later."}
}
// clearSeedScratch removes what a crashed restore or spool left at console
diff --git a/internal/console/teamcreds.go b/internal/console/teamcreds.go
index 3a1fc91b3..baa07ba8c 100644
--- a/internal/console/teamcreds.go
+++ b/internal/console/teamcreds.go
@@ -121,10 +121,10 @@ func (s *Server) scanOwnedEnvironmentRefusal(ctx context.Context, acct, app stri
}
m, _, found, err := appconfig.GetEnvironment(ctx, s.cfg.Releases, acct, app, rec.Environment)
if err != nil {
- return &doorRefusal{http.StatusBadGateway, "could not read the store's environment — try again"}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: "could not read the store's environment — try again"}
}
if found && m.Owned() {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(
"environment %s is owned by team scope %s, and object scanning cannot be enabled for its store: the scan callback secret is derived per app, so it would be the app's own, not the environment's", rec.Environment, m.OwnerScope)}
}
return nil
diff --git a/internal/console/teamenv.go b/internal/console/teamenv.go
index 4e0b9fe1b..b6c6bb857 100644
--- a/internal/console/teamenv.go
+++ b/internal/console/teamenv.go
@@ -102,14 +102,14 @@ func (s *Server) environmentBindingRefusal(ctx context.Context, reg consoleRegis
res := tv.owner(ctx, s, env)
if res.err != nil {
log.Printf("console: environment binding %s/%s (%s): %v", acct.Sqid, app, env, res.err)
- return &doorRefusal{http.StatusBadGateway, "could not read the config — try again"}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: "could not read the config — try again"}
}
owner = res.scope
} else {
m, _, found, err := appconfig.GetEnvironment(ctx, s.cfg.Releases, acct.Sqid, app, env)
if err != nil {
log.Printf("console: environment binding %s/%s (%s): %v", acct.Sqid, app, env, err)
- return &doorRefusal{http.StatusBadGateway, "could not read the config — try again"}
+ return &doorRefusal{Status: http.StatusBadGateway, Msg: "could not read the config — try again"}
}
if found {
owner = m.OwnerScope
@@ -119,7 +119,7 @@ func (s *Server) environmentBindingRefusal(ctx context.Context, reg consoleRegis
return nil
}
if tv == nil && scope != owner {
- return &doorRefusal{http.StatusConflict, ownedBindingMsg(env, owner, host)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: ownedBindingMsg(env, owner, host)}
}
return s.teamFloorRefusal(ctx, reg, placed, region, host, hosting)
}
diff --git a/internal/console/teamfloor.go b/internal/console/teamfloor.go
index 37bb004c1..f2ccf53be 100644
--- a/internal/console/teamfloor.go
+++ b/internal/console/teamfloor.go
@@ -119,11 +119,11 @@ func (s *Server) teamFloorCandidates(ctx context.Context, reg consoleRegistry, p
// placement's C01 or C02.
func (s *Server) teamFloorRefusal(ctx context.Context, reg consoleRegistry, placed, region, host, hosting string) *doorRefusal {
if s.cfg.Releases == nil {
- return &doorRefusal{http.StatusServiceUnavailable, teamFloorUnreadableMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: teamFloorUnreadableMsg}
}
fresh, ok := s.teamFloorCandidates(ctx, reg, placed, region)
if !ok {
- return &doorRefusal{http.StatusServiceUnavailable, teamFloorUnreadableMsg}
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: teamFloorUnreadableMsg}
}
floor := release.TeamEnvironmentFloor.String()
var old *status.Box
@@ -133,7 +133,7 @@ func (s *Server) teamFloorRefusal(ctx context.Context, reg consoleRegistry, plac
continue
}
if hosting != "" && b.Label == hosting {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(teamHostBelowFloorMsg, host, b.Label, floor, boxReleaseWord(b), floor, host)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(teamHostBelowFloorMsg, host, b.Label, floor, boxReleaseWord(b), floor, host)}
}
if old == nil || b.Label < old.Label {
old = &fresh[i]
@@ -143,10 +143,10 @@ func (s *Server) teamFloorRefusal(ctx context.Context, reg consoleRegistry, plac
return nil
}
if fleet, ok := registry.FleetPlacement(placed); ok {
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(teamFleetBelowFloorMsg, fleet, floor, old.Label, boxReleaseWord(*old), floor)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(teamFleetBelowFloorMsg, fleet, floor, old.Label, boxReleaseWord(*old), floor)}
}
name := s.rootfsRegionName(ctx, region)
- return &doorRefusal{http.StatusConflict, fmt.Sprintf(teamRegionBelowFloorMsg, name, floor, old.Label, boxReleaseWord(*old), name, floor)}
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(teamRegionBelowFloorMsg, name, floor, old.Label, boxReleaseWord(*old), name, floor)}
}
// hostingBoxOf is the box label an instance is served from, as the edges