carlos / platform Public

console: file seed review fixes

A reserving file seed gets its own sweep deadline, seedFileReserveTTL:
the upload door's read, check and put deadlines plus a 20-minute margin,
derived from the constants (importCheckBudget is new) so it cannot drift.
Design §3.3 and plan G7 say so. The generic readiness check takes a
seedProtocolRule instead of holding the file door's sentence. Tests for
begin's late failures (aborted with the reason, never deleted) and for a
mismatch that leaves an already-ready seed alone. FS-41 to FS-43
approved; the in-place HA swap in handleAPIInstanceCreate is recorded
under Task 5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 7b9828210dddcd2bc2db239e391a2a0e8c894759 parent 5e1927b
9 files changed, +160 −33
  • docs/superpowers/plans/2026-11-20-fleet-seeded-create.md +6 −4
  • docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md +10 −6
  • internal/console/apiinstanceimport.go +6 −1
  • internal/console/demo_claim_gate_causes_test.go +2 −2
  • internal/console/demo_claim_seed.go +1 −1
  • internal/console/seedfile.go +17 −2
  • internal/console/seedfile_test.go +90 −1
  • internal/console/seedfloor.go +19 −10
  • internal/console/seedsweep.go +9 −6

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md b/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md
index cfe4f5f47..8c1c889bc 100644
--- a/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md
+++ b/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md
@@ -323,6 +323,8 @@ func (s *Server) seedFileReady(ctx context.Context, region string) *doorRefusal
- `runImportUpload` dispatches on `seed.Kind`. The check, the deadlines and the sentences stay the same, except that a file seed's length or sha256 mismatch answers FS-17 in place of SD-N51. For a file seed: put to `s.cfg.SeedData` at `seeds.SnapshotKey`, then `SeedPublishFile`. On failure, `SeedAbortFileUploadBecause`.
- `seedStale`: a `file` seed `reserving` for more than `seedReserveTTL` is stale, as `--from` (design §3.3).
- `seedfinish.go:124`: `KindFile` joins `KindReplica` for the region replica delete. `deleteSeedReplica` already skips anything outside this console's data bucket (`:270`).
+- **Deviation, recorded at the Task 5 review.** "`handleAPIInstanceCreate` does not change" did not hold. Its early HA block (`internal/console/apiinstances.go:2521-2529`) runs for every seeded create in an HA region before the seed door is reached, with `seedPlacementRefusal` and `refuseHAImport`, so FS-16 and FS-20 could never be answered there for a file seed (it got the import's HA sentence and the pool-or-fleet sentence). The two calls were swapped in place for the kind-aware `seedDoorPlacementRefusal(c, req.Import)` and `refuseHASeed(w, &rec, req.Import.Kind)` (`seedfile.go`); the function's line count is unchanged, so the ratchet holds. Import and `--from` answers are unchanged.
+- **The reserving deadline (G7, resolved at the Task 5 review).** A `file` seed's reservation has its own TTL, `seedFileReserveTTL` (`seedfile.go`): `importUploadReadDeadline + importCheckBudget + seedUploadDeadline` plus a 20-minute margin, so it cannot drift from the upload's own deadlines. `--from` keeps `seedReserveTTL`. Test `TestSeedStaleFileReservingOutlivesUploadBudget`.
- [ ] **Step 1: Failing tests** (`seedfile_test.go`, using the import tests' fixtures in `apiinstanceimport_test.go`):
- `TestFileSeedBeginRegionWritesReservingRecord`: 201. The record is `file`, `reserving`, with sha256 and bytes. No snapshot is written yet. No verify token appears in the answer.
@@ -846,9 +848,9 @@ House rules applied: no em dashes; curly apostrophes; placeholders in their orde
| FS-37 | (FS-34's location, `held` staging) moves/%s/ | new | approved (Paul, 2026-11-20) (Decision D12) |
| FS-38 | (FS-34's location, `held` both: FS-36, then FS-37) %s and %s | new | approved (Paul, 2026-11-20) (Decision D12) |
| FS-35 | %s can’t be deleted permanently until its fleet box has cleaned up %s. | %s can’t be purged yet: %s still hold their hostnames until their fleet box has cleaned up. | approved (Paul, 2026-11-20) (the Trash page's "Delete now", and the trash sweep's log) |
-| FS-41 | kind must be file, or left out for an import | new | pending (Task 5) (an import object whose kind is neither absent nor `file`; 400, as the sibling shape sentences SD-N48 and the sha256 rule; only a hand-written API call reaches it) |
-| FS-42 | began seeding %s from a file (%s, %d bytes) | new | pending (Task 5) (the begin's `instance-seed` activity row: host, first 12 of the sha256, length; as the import's "began an import of …") |
-| FS-43 | uploaded the seed file for %s | new | pending (Task 5) (the upload's `seed-file-uploaded` activity row; as the import's "uploaded the snapshot for %s") |
+| FS-41 | kind must be file, or left out for an import | new | approved (Paul, 2026-11-20) (an import object whose kind is neither absent nor `file`; 400, as the sibling shape sentences SD-N48 and the sha256 rule; only a hand-written API call reaches it) |
+| FS-42 | began seeding %s from a file (%s, %d bytes) | new | approved (Paul, 2026-11-20) (the begin's `instance-seed` activity row: host, first 12 of the sha256, length; as the import's "began an import of …") |
+| FS-43 | uploaded the seed file for %s | new | approved (Paul, 2026-11-20) (the upload's `seed-file-uploaded` activity row; as the import's "uploaded the snapshot for %s") |
| — | the upload is not a database that passes an integrity check, so it was not kept. (and the other upload sentences) | same | approved (Paul, 2026-11-20); reused (SD-N52, SD-N61, SD-N67) |
| — | %s places its instances in a pool or on a fleet, so it cannot take a seeded instance. | same | approved (Paul, 2026-11-20); reused, unchanged, for `--from` and import |
| — | (region begin refusals) SD-N2 to SD-N8 and SD-N38 | same | approved (Paul, 2026-11-20); reused |
@@ -894,7 +896,7 @@ House rules applied: no em dashes; curly apostrophes; placeholders in their orde
- **G4. "The row's own database path" is not available at rollback.** The rollback runs only on a pass that finds no row, because `retireAbortedSeedRow` removes it first (`internal/provision/reconcile.go:1963`, `seedreconcile.go:205`). See D5.
- **G5. Nothing carries "a copy of its data is still in the fleet’s storage" to the record.** When cleanup is unproven, design §3.6 has the box report nothing, but it also wants `instances list` to show that reason. The door's only reason-bearing op, `failed`, moves `ready` to `aborted`. D6 widens `SeedFail` to set the reason on an aborted seed. If Paul declines, the reason is not shown.
- **G6. "Refuses ... if any object is there or the listing fails"** (design §3.6, staging) can be read as "report `failed`" for a listing error, which would make a transient S3 error terminal. The plan fails the wake and retries (D7). That is fail-closed either way.
-- **G7. A one-hour reserving deadline against the upload's own deadlines.** The sweep aborts a `file` seed reserving for over an hour (`seedReserveTTL`, `internal/console/seedsweep.go:36`). The upload door allows an hour of reading (`apiinstanceimport.go:299`), 30 minutes of checking (`:287`) and 20 minutes of putting (`apiinstanceseed.go:55`). A large upload can be aborted while still progressing, and its put then lands as an orphan the sweep deletes. Eleven's files are tens of MB. A larger file needs a longer TTL for `file`, or a re-stamp when the upload starts.
+- **G7. A one-hour reserving deadline against the upload's own deadlines.** The sweep aborts a `file` seed reserving for over an hour (`seedReserveTTL`, `internal/console/seedsweep.go:36`). The upload door allows an hour of reading (`apiinstanceimport.go:299`), 30 minutes of checking (`:287`) and 20 minutes of putting (`apiinstanceseed.go:55`). A large upload can be aborted while still progressing, and its put then lands as an orphan the sweep deletes. Eleven's files are tens of MB. A larger file needs a longer TTL for `file`, or a re-stamp when the upload starts. Resolved in Task 5's review fixes: `file` has its own TTL, derived from the upload's deadlines (`seedFileReserveTTL`).
- **G8. The design's names differ from the code's.** `provision.SeedReady` is `SeedPublishReplica` (`internal/provision/seed.go:165`), and `SeedPlaced` is `SeedPlace` (`:189`). The floor fields' producer is `withSeedsFields` (`internal/host/seedsfloor.go:57`), not `edgesfile.go:478`, which only declares them.
- **G9. The floor read arms every customer fleet, not only Eleven's.** The `aclRead` grant is deployment-wide. Once a fleet box runs slice 2 it arms the published floor, and its recovery then refuses a carlos.prev below it (`carlos-system-recover`). That is a behaviour change for every fleet owner, and it should be in the slice 2 release note.
- **G10. `lock.json` sits under the replica prefix** (`internal/lease/lease.go:232`). It is deleted on release, but kept by `Abandon` (`lease.go:715,722`). An exhaustive listing counts it, so a seed whose lease was abandoned holds its hostname until the fleet owner clears the prefix, even if no data was ever uploaded. This is consistent with the invariant. It may surprise people.
diff --git a/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md b/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md
index 2a15c234f..6ea48dfee 100644
--- a/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md
+++ b/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md
@@ -106,9 +106,13 @@ table-driven test row beside the existing kinds:
| a customer fleet | `apps/<sqid>/<app>/seeds/<host>/<id>/snapshot.db` | the deployment bucket |
The console's finish (`seedfinish.go`) and deadline sweep (`seedsweep.go`)
-learn the second key. The sweep's three cases (§3.1) apply unchanged: a
-`file` seed stuck in `reserving` for more than an hour is aborted, as
-`--from` is.
+learn the second key. The sweep's three cases (§3.1) apply, with one
+difference: a `file` seed stuck in `reserving` is aborted after its own
+deadline, `seedFileReserveTTL` (`internal/console/seedfile.go`), not
+`--from`'s hour. Its upload door's budget (an hour to read the body, 30
+minutes to check it, 20 to put it) is past that hour, so the deadline is
+derived from those three plus a margin, 2h10m today, and cannot drift
+from them (amended at the Task 5 review, 2026-11-20).
### 3.4 Readiness and the floor
@@ -220,8 +224,8 @@ an aborted file seed, and the door's `rolledback` operation is the only
way it is reported.
**Abandonment.** A seed is `aborted` by `SeedFail`, by the console's
-deadline sweep (a `file` seed in `reserving` for more than an hour, as
-`--from`), or by the member (`instances delete` before placement). For an
+deadline sweep (a `file` seed in `reserving` past `seedFileReserveTTL`,
+§3.3), or by the member (`instances delete` before placement). For an
`aborted` file seed on a fleet, the owning box's reconcile:
1. fences and stops the host, as the existing rollback does
@@ -255,7 +259,7 @@ fleet-side delete was option (c) and is not part of this design.
**No box owns it.** With no active box (or several and no label), nothing
places or rolls back, and the seed stays where it is. A `reserving` seed
-is aborted by the sweep after an hour, as `--from`; a `ready` seed has no
+is aborted by the sweep after `seedFileReserveTTL` (§3.3); a `ready` seed has no
deadline. Either way the hostname is held until a box owns the record and
proves cleanup. There is no console-side finish for a fleet `file` seed.
diff --git a/internal/console/apiinstanceimport.go b/internal/console/apiinstanceimport.go
index 5f92f45c8..83a438fe1 100644
--- a/internal/console/apiinstanceimport.go
+++ b/internal/console/apiinstanceimport.go
@@ -296,7 +296,7 @@ var (
// checkSeedDBConsole is the upload's integrity check (spec §5.2 step 3).
checkSeedDBConsole = lease.CheckDBContext
// importCheckDeadline bounds that check.
- importCheckDeadline = 30 * time.Minute
+ importCheckDeadline = importCheckBudget
// importSpoolHook, when set, sees the spool once the body is read and
// before it is checked or removed.
importSpoolHook func(path string)
@@ -305,6 +305,11 @@ var (
importReserveHook func(host string)
)
+// importCheckBudget is the upload's integrity check's deadline, a constant
+// so that seedFileReserveTTL can be derived from it; importCheckDeadline is
+// its test seam.
+const importCheckBudget = 30 * time.Minute
+
// importUploadReadDeadline is how long the upload's body may take to
// arrive: up to 4 GiB, past the server's ReadTimeout. It covers the body
// read only; the check and the put run after the answer.
diff --git a/internal/console/demo_claim_gate_causes_test.go b/internal/console/demo_claim_gate_causes_test.go
index 9b99fa950..b83722118 100644
--- a/internal/console/demo_claim_gate_causes_test.go
+++ b/internal/console/demo_claim_gate_causes_test.go
@@ -99,7 +99,7 @@ func TestDemoClaimReadinessSeedRefusalCauses(t *testing.T) {
s, _, _ := claimTestServer(t)
claimActivationFixture(t, s)
tc.change(t, s)
- if s.seedRegionReadyForEdges(t.Context(), s.cfg.Region, false, 0, demoClaimEdge) == nil {
+ if s.seedRegionReadyForEdges(t.Context(), s.cfg.Region, false, nil, demoClaimEdge) == nil {
t.Fatal("fixture did not reach an existing seed refusal")
}
var output bytes.Buffer
@@ -198,7 +198,7 @@ func TestDemoClaimSeedCauseChecksPreserveAcceptance(t *testing.T) {
t.Fatal(err)
}
}
- if ref := s.seedRegionReadyForEdges(t.Context(), s.cfg.Region, false, 0, demoClaimEdge); ref != nil {
+ if ref := s.seedRegionReadyForEdges(t.Context(), s.cfg.Region, false, nil, demoClaimEdge); ref != nil {
t.Fatalf("existing refusal: %+v", ref)
}
if gates := s.demoClaimSeedGates(t.Context(), s.cfg.Region); len(gates) != 0 {
diff --git a/internal/console/demo_claim_seed.go b/internal/console/demo_claim_seed.go
index aca779344..66e9ee8b3 100644
--- a/internal/console/demo_claim_seed.go
+++ b/internal/console/demo_claim_seed.go
@@ -47,7 +47,7 @@ func (s *Server) demoClaimSeedGates(ctx context.Context, region string) demoClai
if s.cfg.Releases == nil {
return gates
}
- gates.check("seed-region", s.seedRegionReadyForEdges(ctx, region, false, 0, demoClaimEdge) == nil)
+ gates.check("seed-region", s.seedRegionReadyForEdges(ctx, region, false, nil, demoClaimEdge) == nil)
floor, err := seeds.ReadFloor(ctx, s.cfg.Releases)
gates.check("seed-floor", err == nil && floor != nil && floor.Min >= seeds.DemoClaimProtocol)
if floor != nil {
diff --git a/internal/console/seedfile.go b/internal/console/seedfile.go
index 84217002f..705fd7df6 100644
--- a/internal/console/seedfile.go
+++ b/internal/console/seedfile.go
@@ -27,6 +27,20 @@ import (
"github.com/carlosframework/platform/internal/seeds"
)
+// seedFileReserveTTL is how long a file seed may stay reserving before the
+// seeds sweep abandons it. It is the upload door's whole budget, derived
+// from the deadlines themselves so the two cannot drift: an hour to read
+// the body (importUploadReadDeadline), 30 minutes to check it
+// (importCheckBudget) and 20 minutes to put it (seedUploadDeadline), plus a
+// margin for the gap between begin, which stamps the seed's At, and the
+// upload's start, the record reads and writes around them, and clock skew
+// between consoles. A sweep inside it would abort an upload still in
+// progress, and its put would then land as an orphan (plan G7).
+const seedFileReserveTTL = importUploadReadDeadline + importCheckBudget + seedUploadDeadline + seedFileReserveMargin
+
+// seedFileReserveMargin is seedFileReserveTTL's margin over the budget.
+const seedFileReserveMargin = 20 * time.Minute
+
// createFileSeed is the file seed's begin, held like the import's so that
// every refusal reaches the caller after anything the door wrote has been
// put on its way out.
@@ -220,7 +234,8 @@ func (s *Server) refuseHASeed(w http.ResponseWriter, rec *provision.Record, kind
// seedStorageRefusal is the one answer to "can this console store this
// seed's snapshot" (plan R2-2), asked by begin and by the upload alike so
-// the two never disagree. placement is the record's Region column. An
+// the two never disagree. placement is the record's Region column.
+// kind and placement are unused until slice 3's fleet branch reads them. An
// import and a region file seed need this console's data bucket and the
// hibernation bucket its replicas live in; the refusal is the import's,
// byte for byte (seedNoDataRefusal). Slice 3 adds the fleet file seed's
@@ -238,7 +253,7 @@ func (s *Server) seedStorageRefusal(kind, placement string) *doorRefusal {
// There is no one-box rule: a region file seed is --from-shaped, placed by
// whichever box wakes it, with no swap and no journal (plan R1-3).
func (s *Server) seedFileReady(ctx context.Context, region string) *doorRefusal {
- return s.seedRegionReadyForEdges(ctx, region, false, seeds.FileSeedProtocol, nil)
+ return s.seedRegionReadyForEdges(ctx, region, false, &seedProtocolRule{min: seeds.FileSeedProtocol, belowFloor: fileSeedFloorCopy}, nil)
}
// seedUploadReady is the upload's readiness re-check, by the seed's kind:
diff --git a/internal/console/seedfile_test.go b/internal/console/seedfile_test.go
index 60c5f273d..871014073 100644
--- a/internal/console/seedfile_test.go
+++ b/internal/console/seedfile_test.go
@@ -12,6 +12,7 @@ import (
"testing"
"time"
+ "github.com/carlosframework/platform/internal/objstore"
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/seeds"
@@ -352,7 +353,7 @@ func TestSeedsPassAbortsStuckFileReservation(t *testing.T) {
f := newSweepFixture(t)
now := time.Now()
live := f.seeded(t, "live.shop.example.com", seeds.KindFile, seeds.StateReserving, now.Add(-10*time.Minute))
- stuck := f.seeded(t, "stuck.shop.example.com", seeds.KindFile, seeds.StateReserving, now.Add(-2*time.Hour))
+ stuck := f.seeded(t, "stuck.shop.example.com", seeds.KindFile, seeds.StateReserving, now.Add(-seedFileReserveTTL-time.Minute))
ready := f.seeded(t, "ready.shop.example.com", seeds.KindFile, seeds.StateReady, now.Add(-2*time.Hour))
liveKey := f.snapshot(t, "live.shop.example.com", live, 10*time.Minute)
stuckKey := f.snapshot(t, "stuck.shop.example.com", stuck, 90*time.Minute)
@@ -369,6 +370,94 @@ func TestSeedsPassAbortsStuckFileReservation(t *testing.T) {
}
}
+// The sweep must never abort a file seed whose upload is still inside the
+// door's own deadlines (plan G7): the TTL is past their sum, and a
+// --from reservation keeps its hour.
+func TestSeedStaleFileReservingOutlivesUploadBudget(t *testing.T) {
+ budget := importUploadReadDeadline + importCheckDeadline + seedUploadDeadline
+ if seedFileReserveTTL <= budget {
+ t.Fatalf("seedFileReserveTTL %s does not outlast the upload's budget %s", seedFileReserveTTL, budget)
+ }
+ now := time.Now()
+ file := func(age time.Duration) *provision.SeedSource {
+ return &provision.SeedSource{ID: "sd_x", Kind: seeds.KindFile, State: seeds.StateReserving, At: now.Add(-age)}
+ }
+ if seedStale(file(budget+time.Minute), now) {
+ t.Fatal("a file seed just past the upload's budget was judged stale")
+ }
+ if !seedStale(file(seedFileReserveTTL+time.Minute), now) {
+ t.Fatal("a file seed past seedFileReserveTTL was not judged stale")
+ }
+ replica := &provision.SeedSource{ID: "sd_y", Kind: seeds.KindReplica, State: seeds.StateReserving, At: now.Add(-seedReserveTTL - time.Minute)}
+ if !seedStale(replica, now) {
+ t.Fatal("a --from reservation past its hour was not judged stale")
+ }
+}
+
+// A begin that fails after its record is written aborts the seed with the
+// refusal as its reason; the record is never deleted (a box may hold a row).
+func TestFileSeedBeginStoreFailureAbortsNotDeletes(t *testing.T) {
+ f := newFileSeedFixture(t)
+ enableInstances(t, f.fx, fromApp, fromManifest(true))
+ // Another environment's store already uses the name the walk derives.
+ if _, err := objstore.PutIn(context.Background(), f.fx.rel, "bab", fromApp, "staging", grantedStore("carlos-bab-shop-old"), ""); err != nil {
+ t.Fatal(err)
+ }
+ const want = "another store already uses this instance's storage names (app and environment names are joined with \"-\"), so the instance was not created. use a different host name"
+ code, out := f.create(t, fileSeedBody(importHost, importSHA, 10))
+ if code != http.StatusConflict || str(t, out, "error") != want {
+ t.Fatalf("= %d %v", code, out)
+ }
+ rec, err := f.record(t, importHost)
+ if err != nil || rec.Seed == nil {
+ t.Fatalf("record = %+v, %v; want it kept, aborted", rec, err)
+ }
+ requireFileState(t, rec, rec.Seed.ID, seeds.StateAborted, want)
+}
+
+func TestFileSeedBeginSiblingApexAbortsNotDeletes(t *testing.T) {
+ f := newFileSeedFixture(t)
+ f.fx.srv.cfg.AppsDomain = "apps.example.net"
+ m := fromManifest(true)
+ m.Domain = "bab.apps.example.net"
+ enableInstances(t, f.fx, fromApp, m)
+ f.fx.srv.cfg.StoreProvisioner = &apexOnBucket{MemProvisioner: f.fake, f: f, label: "old"}
+ const host = "old.bab.apps.example.net"
+ const want = "old.bab.apps.example.net is app old's platform apex. That app was created while this instance was being written, so the instance was not kept."
+ code, out := f.create(t, fileSeedBody(host, importSHA, 10))
+ if code != http.StatusConflict || str(t, out, "error") != want {
+ t.Fatalf("= %d %v", code, out)
+ }
+ rec, err := f.record(t, host)
+ if err != nil || rec.Seed == nil {
+ t.Fatalf("record = %+v, %v; want it kept, aborted", rec, err)
+ }
+ requireFileState(t, rec, rec.Seed.ID, seeds.StateAborted, want)
+}
+
+// The mismatch abort acts only while the seed still waits: a seed another
+// upload published meanwhile is left ready, with no reason.
+func TestFileSeedUploadMismatchLeavesAPublishedSeed(t *testing.T) {
+ f := newFileSeedFixture(t)
+ body, _ := sqliteBytes(t)
+ begun := f.beginFile(t, fileHost, body)
+ id := begun.Seed.ID
+ defer func() { importSpoolHook = nil }()
+ importSpoolHook = func(string) {
+ if _, err := provision.SetRecordSeed(context.Background(), f.fx.rel, "bab", fromApp, fileHost, provision.SeedPublishFile(id)); err != nil {
+ t.Error(err)
+ }
+ }
+ if code, out := uploadImport(t, f, fileHost, body[:len(body)-1]); code != http.StatusUnprocessableEntity || str(t, out, "error") != fileSeedMismatchCopy {
+ t.Fatalf("mismatched upload = %d %v, want 422 FS-17", code, out)
+ }
+ rec, err := f.record(t, fileHost)
+ if err != nil {
+ t.Fatal(err)
+ }
+ requireFileState(t, rec, id, seeds.StateReady, "")
+}
+
func TestFinishFileSeedDeletesRegionReplica(t *testing.T) {
f := finishFixture(t)
id := newSeedID(t)
diff --git a/internal/console/seedfloor.go b/internal/console/seedfloor.go
index 75ffab549..d93671e46 100644
--- a/internal/console/seedfloor.go
+++ b/internal/console/seedfloor.go
@@ -33,17 +33,23 @@ import (
// box whose own local floor is unreadable publishes "" for its floor, and
// must never be read as ready.
func (s *Server) seedRegionReady(ctx context.Context, region string, oneBox bool) *doorRefusal {
- return s.seedRegionReadyForEdges(ctx, region, oneBox, 0, nil)
+ return s.seedRegionReadyForEdges(ctx, region, oneBox, nil, nil)
+}
+
+// seedProtocolRule is what a seed door newer than the first ones asks of
+// the floor and the boxes: the published floor's Min must reach min, else
+// the floor predates the door and belowFloor is the 409's sentence; and
+// every box must report at least min. The first doors pass nil and keep
+// seeds.RequiredProtocol.
+type seedProtocolRule struct {
+ min int
+ belowFloor string
}
// Demo claims only use shared-pool edges. Other seed operations pass nil and
// retain the region-wide checks, including layout and host-claim readiness.
-//
-// protocol is the seeds protocol the door needs above the doors that came
-// first (0 for those, which keep seeds.RequiredProtocol): the published
-// floor's Min must reach it, else the floor predates the door (FS-25, the
-// file door's, seedFileReady), and every box must report at least it.
-func (s *Server) seedRegionReadyForEdges(ctx context.Context, region string, oneBox bool, protocol int, include func(edgesFilePlacementView) bool) *doorRefusal {
+// rule is a newer door's protocol (seedProtocolRule), nil for the first.
+func (s *Server) seedRegionReadyForEdges(ctx context.Context, region string, oneBox bool, rule *seedProtocolRule, include func(edgesFilePlacementView) bool) *doorRefusal {
region = s.homeRegionIn(region)
if s.cfg.HostClaim {
return seedClaimConsoleRefusal()
@@ -64,10 +70,13 @@ func (s *Server) seedRegionReadyForEdges(ctx context.Context, region string, one
if floor == nil {
return &doorRefusal{Status: http.StatusConflict, Msg: "This deployment has no seeds floor yet. An operator publishes it with carlos system seeds-floor publish."}
}
- if floor.Min < protocol {
- return &doorRefusal{Status: http.StatusConflict, Msg: fileSeedFloorCopy}
+ minProtocol := max(seeds.RequiredProtocol, floor.Min)
+ if rule != nil {
+ if floor.Min < rule.min {
+ return &doorRefusal{Status: http.StatusConflict, Msg: rule.belowFloor}
+ }
+ minProtocol = max(minProtocol, rule.min)
}
- minProtocol := max(seeds.RequiredProtocol, floor.Min, protocol)
name := s.homeRegionOut(region)
if name == "" {
name = "the home region"
diff --git a/internal/console/seedsweep.go b/internal/console/seedsweep.go
index 6646d46aa..0ee41ddbd 100644
--- a/internal/console/seedsweep.go
+++ b/internal/console/seedsweep.go
@@ -32,7 +32,8 @@ const (
// queues behind holders of up to storeTeardownTimeout each, this
// sweep's own finishes among them. A copy that overruns the hour that
// way is aborted by a CAS with one winner: the user retries, and no
- // data is lost.
+ // data is lost. A file seed's reservation has its own, longer TTL
+ // (seedFileReserveTTL): its upload door's budget is past this hour.
seedReserveTTL = time.Hour
// seedImportTTL is how long an import may wait for its upload, or for
// the app to say its process is stopped.
@@ -86,10 +87,10 @@ func (s *Server) seedsIteration(ctx context.Context) {
})
}
-// seedStale reports a seed stuck where no box moves it: a --from seed, or a
-// file seed waiting for its upload (fleet seeded create design §3.3),
-// reserving for over seedReserveTTL, or an import waiting for its upload or
-// its stop for over seedImportTTL. Both times are a console's: At is
+// seedStale reports a seed stuck where no box moves it: a --from seed
+// reserving for over seedReserveTTL, a file seed reserving (waiting for its
+// upload) for over seedFileReserveTTL (fleet seeded create design §3.3),
+// or an import waiting for its upload or its stop for over seedImportTTL. Both times are a console's: At is
// stamped by the console whose door reserved or began the seed, now is the
// sweeping console's. With one console per deployment they are one clock;
// with more (region HA) their skew comes off the reservation's margin of
@@ -102,8 +103,10 @@ func seedStale(seed *provision.SeedSource, now time.Time) bool {
return false
case seed == nil:
return false
- case (seed.Kind == seeds.KindReplica || seed.Kind == seeds.KindFile) && seed.State == seeds.StateReserving:
+ case seed.Kind == seeds.KindReplica && seed.State == seeds.StateReserving:
return now.Sub(seed.At) > seedReserveTTL
+ case seed.Kind == seeds.KindFile && seed.State == seeds.StateReserving:
+ return now.Sub(seed.At) > seedFileReserveTTL
case seed.Import() && (seed.State == seeds.StateAwaitingUpload || seed.State == seeds.StateUploaded):
return now.Sub(seed.At) > seedImportTTL
}