activator: a join waits for its build install; not a crash (#1061)
A copy joining a fresh fleet box had its wakes refused "no build is installed for this instance yet" until root stamped the install. The refusal counted as a crash (resident backoff 1, 2, 4 ... 60 s), and past replicaRestartBound (32 s) the permitted step answered switched with the build failed, which halts the deploy falsely. - rollout: the five not-installed refusal sites return notInstalledPlan(), marked WakePlan.Installing (no text comparison anywhere). - activator: an Installing refusal is errBuildNotInstalled (text unchanged); residentFailure does not count it, and residentState records installSince beside configSince. - replicaRestartedFailure keeps the step open while installSince is within releaseInstallBound (10 min); past it the answer is kept with keptInstall and reason SR-6-C01 (pending Paul review), never switched. - W1 TestJoinInstallWaitKeepsStepOpen and TestNotInstalledRefusalsAreMarkedInstalling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md+1 −0internal/activator/activator.go+1 −1internal/activator/claimwake.go+1 −1internal/activator/replica_install_wait_test.go+138 −0internal/activator/replicadeploy.go+42 −9internal/activator/rootfs_service.go+16 −1internal/activator/wakeplan.go+29 −0internal/rollout/wakeplan.go+19 −5internal/rollout/wakeplan_test.go+75 −0
Intent
<task-notification> <task-id>ac863f202b7bd21fa</task-id> <tool-use-id>toolu_01V8TFvJyyDLPBq1jPfiEQL2</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/ac863f202b7bd21fa.output</output-file> <status>completed</status> <summary>Agent "Triage #966 fleet box 404s" 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>Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/sr-followups/.superpowers/sdd/2026-11-14-sr-followups/966-triage.md (197 lines). No code was changed and no scratch files were made. **Summary** 1. **Where the writes go.** A fleet box with no bucket settings uses the hub edge's store door (`internal/fleetapi`, using `CARLOS_TUNNEL_URL` and the tunnel token). It does not talk to the console or to S3. That store uses platform-root keys with no prefix. The drill journals show only two kinds of 404: a write to `control/config-ack/<label>/<host>.json` (3 lines) and a **list** of the root `status/boxes/` (89 lines). The list is the alias pass reading other boxes' snapshots (`edgesfile.DeploymentRoutesComplete`, agent.go:1520). The box's own snapshot write already works, because it goes to `fleets/<fleet>/status/boxes/`. 2. **Why it 404s.** "404 page not found" here is not a missing route. It is `http.NotFound`, which the door sends for every refusal on purpose (`internal/edge/storedoor.go`). Box writes are only allowed under `fleets/<fleet>/**` and under the app log, errors and analytics folders (`aclWrite`, storedoor.go:807). Listing `status/boxes/` is never allowed (`aclListScope`, :882). The door is right to refuse both: allowing them would let one tenant read or tamper with others' data. The client is the bug. The status and metrics loops already got this fix in August (`resolveStatusPrefix`, a5c6cc35); the config-ack writer and the alias pass never did. 3. **History.** The `status/boxes/` 404 dates from 2026-08-27 (c567b1d3) and the config-ack 404 from 2026-09-07 (46f7c832). Both are months older than stateless replicas Plan 4 (ae1b8cca, 2026-11-12). No server route was ever added, and none should be. 4. **What is lost.** Nothing unsafe; every effect fails closed. - `carlos relay status` never shows "adopted" for a fleet app's routes; it stays "awaiting delivery". - The alias pass on fleet boxes is always incomplete. The edge asset cache never turns on there, the startup HA ingress pass uses all four attempts on every boot, and the journal fills with these lines. - Moves also read acks, but they refuse fleet apps, so they are not affected. Config receipts #522 does not read acks yet. 5. **Fix: change the clients, not the door.** - Config acks: on the door branch, write them under `fleets/<fleet>/control/config-ack/...`. The console's ack reader (`relayConfigAcks`) should also read that folder, and only for hosts whose app is placed on that fleet. - Alias pass: on a door box, skip the snapshot read and pass an empty, complete route set. Fleet boxes publish no edges files, and the cross-box guard is already off for them today. - Tests should go next to `TestDoorBackedStatusWriteLandsInTheFleetCorner`, in the `newBindDoor` harness, and in the door's access-rule tables (to pin that both refusals stay). - The `internal/host` change needs a census card. No user-facing wording changes. **Open questions** 1. The alias-pass fix turns on the asset cache and complete HA ingress alias publication on fleet boxes for the first time. Is that wanted, or should the pass stay incomplete and just log less? 2. Should the door check that an ack's `<label>` folder matches the box's own login? Or is the current trust enough, where any box in a fleet can write anywhere under that fleet (the same as bindings and status today)? 3. A separate finding: the door refuses reads of `control/host-incarnations/<host>.json`, so a box with claims off would read that record as absent. The drill only showed timeouts there, so this is unconfirmed. 4. `control/relay-ack/<box>.json` would hit the same refusal if relay members run on fleet boxes. Do they?</result> <usage><subagent_tokens>146073</subagent_tokens><tool_uses>65</tool_uses><duration_ms>492931</duration_ms></usage> </task-notification>
<task-notification> <task-id>a83a4989794ca233d</task-id> <tool-use-id>toolu_01UWdJSXVfTc9TDhVuv4awpX</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/a83a4989794ca233d.output</output-file> <status>completed</status> <summary>Agent "Investigate #1061 join Failed window" 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>The report is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/sr-followups/.superpowers/sdd/2026-11-14-sr-followups/1061-investigation.md` (141 lines). This was read only: no code changed, nothing committed, no scratch files. **Summary** 1. **Where "Failed" comes from:** only the hub. The console box's edge probes each copy once a second and calls a copy "failed" after two misses, even if that copy has never once passed (`internal/edge/replicaprober.go:278-286`). So every joining copy reads Failed: while it is placed but not set up, while its starts are refused, and through its 39 s app boot. There is no starting or installing state today. The cheapest fix is to keep a copy that has never passed at "unknown" with the existing text "waiting for this copy to pass its health check". Older CLIs would show such a state as "Unknown". 2. **The 1m47s gap:** setting copies writes config but not the box assignment. Only the console's FleetRelabel pass writes that, every 5 minutes (`fleetrelabel.go:59`). Once it does, box-2 notices within about 2 s. Nothing nudges placement when copies change; the drain door is the precedent for adding a nudge. 3. **Root pass pickup:** it is a path unit (`carlos-stage.path`), not a timer, and it took about 1 s (17:58:17 to :18). The 13 s before generation 3 started is something else: each refused start is counted as a crash, so retries back off 1, 2, 4 … up to 60 s. 4. **A real bug behind the permit:** a joining copy whose build file is on the box but not yet installed has 32 s (`replicaRestartBound`). After that its step answers "switched, failed", and the deploy halts with "the new build stopped working on box-2 after its switch". This incident escaped only because root finished in 1 s. I recommend counting the install wait inside the bound, the way the existing config wait already works. The alternative, granting the permit only once the build is installed, needs a record and wire change. 5. **The repoint line:** the agent's attempt is how it asks root for the install, so the attempt has to stay. Only the "repoint failed" print is noise. It can be skipped when the request to root is about to be sent, which leaves the root pass and real errors logging as before. The report also lists seven ordered tasks with tests, led by a witness on the real activator test rig that fails on main today. **Copy review needed:** - A new reason for a join that gives up waiting: "the new copy's build was not installed on its box in time, so it did not start. existing copies keep serving" (a sibling of SR-4-C92). - A new "Starting" copy state label and its health cell. - "Installing" as distinct from "Starting" would need the box to tell the hub, plus one more label. **Open questions** - Can we get the box-2 "wake failed" lines for 17:58:19–:29 without the collapsing? I need to know whether they still said "no build is installed" or "this instance is still moving to another build". - Can we get the console's FleetRelabel run times for 17:56–17:58, to confirm when placement ran? - When exactly did the operator see Failed? By the code, the Failed window was about one minute (17:58:13 to 17:59:11), not three. The copies table cannot appear before placement. - How long should a join wait for its install before giving up? I suggested 10 minutes. And should the hub's "never passed" state also turn into failed after some limit? - Does Paul want "Installing" separate from "Starting"? - The repoint print fix touches `adopt.go`, which runs in the root pass. It is print-only, but the census reviewer should confirm whether it needs a card. - Placement code should stay out of `fleetrelabel.go`, which belongs to the other controller (paseo 082be174).</result> <usage><subagent_tokens>222665</subagent_tokens><tool_uses>92</tool_uses><duration_ms>735664</duration_ms></usage> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="082be174-b358-4fb5-98c4-843ba5cb7734" message-id="4a7d8191-db9c-48d8-81bc-ff90c27666a3" source-agent-title="Fleet record labels build (#1008, SDD controller)"> From 082be17 (fleet record labels): yes, please go ahead. My branches are merged (M2 is ac9ee364 on main), so you won't collide with me. A CLI-only change in instances_cli.go is the right size. Four notes: 1. Cover boxes too, not only the console. labelFloorBox sets FloorBox to a box name, or "console", and FloorRelease to that box's reported release, or "unknown" when it hasn't reported. A box running a hash build hits the same silent floor. Keep three cases apart: - FloorRelease doesn't parse as a release: your new string, worded for "the console" or for the box. - FloorRelease is "unknown": the existing C29 wording is fine. - Otherwise: C29 as now. 2. Copy keys. The deck is docs/drafts/fleet-record-labels/strings.json, approved copy C01-C50. Give the new string the next key, C51, with the marker "// draft for copy review (C51)", and add a deck entry with status pending. Then run: go test . -run 'TestInstancesLabelCopyKeysPresent|TestFleetRecordLabelsApprovedCopyApplied|TestInstancesLabel' -count=1 The applied-copy test checks the marked strings against the deck. For review, Paul's standing delegation sends plan CLI copy to Luna; the brief is docs/drafts/fleet-record-labels/LUNA-COPY-BRIEF.md. Check with 8a3d302 whether this one goes to Paul or to Luna. 3. D1 has the same problem without a CLI hook. On a console with a non-release build, every process create on a multi-box fleet answers 503 C39 ("no box of fleet %s can take a new instance right now. try again in a minute"). That reads as transient, and retrying never helps. Fixing it would mean a console change in internal/console/fleetcreate.go (fleetCreateLabel, the fleetAtRecordFloor case). It's worth naming on #1060 even if you leave it out of this change. 4. No wire change is needed for the label path. FloorRelease already carries the raw build string. </paseo-system>
Attributed to this commit: 13.4 g CO₂e (1,484,079 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on sr-followups, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md| index fd1d26836..5e392f02d 100644 |
| --- a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md |
| +++ b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md |
| @@ -168,3 +168,4 @@ copy too. Internal wire enums are not an excuse to expose unreviewed text. |
| | SR-4-C94 | docs/site/stateless-replicas.md | When a copy switches, its old build stops once the new one serves. A response still streaming from the old build when it stops is cut, as when a box stops. Websockets on the old build disconnect and their clients reconnect to a healthy copy. | approved (controller; Luna house rules) (drill 3, H4) | |
| | SR-4-C95 | internal/console/appcopies.go | <host> is not tied to one box of fleet <fleet>, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now | pending (superseded 2026-11-14 by fleet record labels C41, which points at carlos instances label; this text was approved by Paul as SR-5-C01 in copy review u4k4cyxedlsfh72a7vpq3sn2uu; the new text goes to Paul's copy review in docs/drafts/fleet-record-labels/copy-review) | |
| | SR-4-C96 | internal/console/appcopies.go | <host> runs a release without a local database and is not tied to a box of fleet <fleet>, so a second active box would stop it. move it to a release with a local database before adding a box | pending (superseded 2026-11-14 by fleet record labels C40, which points at carlos instances label; this text was approved by Paul as SR-5-C02 in copy review u4k4cyxedlsfh72a7vpq3sn2uu; the new text goes to Paul's copy review in docs/drafts/fleet-record-labels/copy-review) | |
| +| SR-6-C01 | internal/activator/replicadeploy.go | the new copy's build was not installed on its box in time, so it did not start. existing copies keep serving | pending (Paul review, #1061) | |
diff --git a/internal/activator/activator.go b/internal/activator/activator.go| index 4d9f131a2..54150f90e 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -2851,7 +2851,7 @@ func (a *Service) doWakeOnce(ctx context.Context, e *actEntry) (*wokenInstance, |
| } |
| plan = a.Planner(ctx, rt) |
| if plan.Refuse != "" { |
| - return w, fmt.Errorf("%s: refusing to wake: %s", host, plan.Refuse) |
| + return w, planRefusal(host, plan) |
| } |
| a.mu.Lock() |
| e.plan, e.firstWake = plan, plan.FirstWake |
diff --git a/internal/activator/claimwake.go b/internal/activator/claimwake.go| index ba886852a..9f523c919 100644 |
| --- a/internal/activator/claimwake.go |
| +++ b/internal/activator/claimwake.go |
| @@ -272,7 +272,7 @@ func (a *Service) doClaimWake(ctx context.Context, e *actEntry) (*wokenInstance, |
| } |
| plan := a.Planner(ctx, rt) |
| if plan.Refuse != "" { |
| - return nil, fmt.Errorf("%s: refusing to wake: %s", rt.Host, plan.Refuse) |
| + return nil, planRefusal(rt.Host, plan) |
| } |
| if plan.planned() { |
| pin := genOf(plan.Boot) |
diff --git a/internal/activator/replica_install_wait_test.go b/internal/activator/replica_install_wait_test.go| new file mode 100644 |
| index 000000000..ef3203f8b |
| --- /dev/null |
| +++ b/internal/activator/replica_install_wait_test.go |
| @@ -0,0 +1,138 @@ |
| +package activator |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "slices" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/replicas" |
| +) |
| + |
| +// TestJoinInstallWaitKeepsStepOpen (#1061 W1): a joining permit holder |
| +// whose wakes are refused because no build is installed on its box yet |
| +// (WakePlan.Installing, errBuildNotInstalled) keeps its step open past |
| +// replicaRestartBound, up to releaseInstallBound from the first such |
| +// refusal, and is never answered switched-failed. The refusal is no crash: |
| +// it grows no resident backoff, so the next tick after root's stamp starts |
| +// the copy. |
| +// - installed at 60 s: the step stays open through the wait, the copy |
| +// launches once the planner boots it, and the step proves the switch. |
| +// - never installed: past releaseInstallBound the step answers kept with |
| +// the install reason (SR-6-C01); the ACK halts the join and the box is |
| +// not in Completed. |
| +func TestJoinInstallWaitKeepsStepOpen(t *testing.T) { |
| + prev := swapSettle |
| + swapSettle = 20 * time.Millisecond |
| + t.Cleanup(func() { swapSettle = prev }) |
| + join := func(inc string) *replicas.Deploy { |
| + return &replicas.Deploy{ID: "deploy-v2", Incarnation: inc, Target: replicaTarget, BaselineSet: true, LastGood: replicaTarget, Phase: "released", Term: "term", Revision: 5, |
| + Swap: replicas.Swap{Order: []string{"a", "b"}, Completed: []string{"a"}, ActiveBox: "b", Permit: 5}} |
| + } |
| + notInstalled := WakePlan{Refuse: "no build is installed for this instance yet", Installing: true, Token: 2} |
| + setup := func(t *testing.T) (*replicaSetRig, func() error, func(bool) SwapResult) { |
| + r := newReplicaSetRig(t, "b", join) |
| + r.rt.Hibernate = false |
| + r.routes.set(r.rt) |
| + r.setPlan(notInstalled) |
| + wake := func() error { return waitErr(t, r.wake(r.a)) } |
| + step := func(awake bool) SwapResult { |
| + at := Attempt{Host: r.rt.Host, Cause: CauseRelease, Build: "v2", StagedPath: r.next.StagedPath, Mode: ModeOverlap, SchedRev: 1, ProofOnly: true} |
| + if awake { |
| + at = r.attempt(CauseRelease, ModeOverlap) |
| + } |
| + return r.a.ReplicaSwap(context.Background(), at, *r.store.snapshot(), "b", newestOne) |
| + } |
| + return r, wake, step |
| + } |
| + // refused wakes once, asserts the typed refusal with its text |
| + // unchanged, and that it set no resident backoff. |
| + refused := func(t *testing.T, r *replicaSetRig, wake func() error, when string) { |
| + t.Helper() |
| + err := wake() |
| + if !errors.Is(err, errBuildNotInstalled) { |
| + t.Fatalf("%s: the wake was not refused as not installed: %v", when, err) |
| + } |
| + if want := r.rt.Host + ": refusing to wake: no build is installed for this instance yet"; err.Error() != want { |
| + t.Fatalf("%s: the refusal's text changed: %q, want %q", when, err.Error(), want) |
| + } |
| + r.a.mu.Lock() |
| + st := r.a.residents[r.rt.Host] |
| + var failures int |
| + var retryAt, since time.Time |
| + if st != nil { |
| + failures, retryAt, since = st.failures, st.retryAt, st.installSince |
| + } |
| + now := r.a.now() |
| + r.a.mu.Unlock() |
| + if failures != 0 || retryAt.After(now) { |
| + t.Fatalf("%s: the not-installed refusal was counted as a crash: failures %d, retry in %s", when, failures, retryAt.Sub(now)) |
| + } |
| + if since.IsZero() { |
| + t.Fatalf("%s: the install wait was not recorded", when) |
| + } |
| + } |
| + open := func(t *testing.T, res SwapResult, when string) { |
| + t.Helper() |
| + if res.Proven || res.WebFailed { |
| + t.Fatalf("%s: the waiting copy's step answered: %+v", when, res) |
| + } |
| + } |
| + t.Run("installed at 60s", func(t *testing.T) { |
| + r, wake, step := setup(t) |
| + refused(t, r, wake, "first wake") |
| + open(t, step(false), "at once") |
| + r.clk.advance(60 * time.Second) |
| + refused(t, r, wake, "wake at 60s") |
| + open(t, step(false), "past replicaRestartBound") |
| + r.setPlan(WakePlan{Boot: r.next, Mode: ModeOverlap, Token: 3}) |
| + if err := wake(); err != nil { |
| + t.Fatalf("wake with the build installed: %v", err) |
| + } |
| + r.a.mu.Lock() |
| + since := r.a.residents[r.rt.Host].installSince |
| + r.a.mu.Unlock() |
| + if !since.IsZero() { |
| + t.Fatal("a successful wake left the install wait recorded") |
| + } |
| + res := step(true) |
| + if res.Outcome != SwapDone || !res.Proven || res.WebFailed { |
| + t.Fatalf("the joined copy's switch was not proven: %+v", res) |
| + } |
| + }) |
| + t.Run("never installed", func(t *testing.T) { |
| + r, wake, step := setup(t) |
| + refused(t, r, wake, "first wake") |
| + open(t, step(false), "at once") |
| + for gone := time.Duration(0); gone <= releaseInstallBound; gone += 50 * time.Second { |
| + r.clk.advance(50 * time.Second) |
| + refused(t, r, wake, "wake after "+(gone+50*time.Second).String()) |
| + if gone+50*time.Second < releaseInstallBound { |
| + open(t, step(false), "within the bound") |
| + } |
| + } |
| + res := step(false) |
| + if !res.Proven || res.WebFailed || res.Outcome == SwapDone || res.Reason != replicaInstallRefusal { |
| + t.Fatalf("past the bound, not answered kept for the install: %+v", res) |
| + } |
| + if again := step(false); !again.Proven || again.WebFailed || again.Reason != replicaInstallRefusal { |
| + t.Fatalf("the repeated step did not keep its answer: %+v", again) |
| + } |
| + if err := wake(); !errors.Is(err, ErrFenced) { |
| + t.Fatalf("a wake before the ACK was not refused by the kept fence: %v", err) |
| + } |
| + cur := *r.store.snapshot() |
| + next, err := replicas.NextDeploy(cur, replicas.DeployChange{Op: "ack", ID: cur.ID, Box: "b", Revision: cur.Revision, Target: cur.Target, Permit: cur.Swap.Permit}, replicas.Coordinator{}, time.Now()) |
| + if err != nil || next.PermitOutstanding() || !next.Swap.Halted || slices.Contains(next.Swap.Completed, "b") { |
| + t.Fatalf("the join did not halt with b out of Completed: %v %+v", err, next.Swap) |
| + } |
| + r.a.SetReplicaDeploy(r.rt.Host, next, "b") |
| + r.a.mu.Lock() |
| + fence := r.a.fences[r.rt.Host] |
| + r.a.mu.Unlock() |
| + if fence != 0 { |
| + t.Fatalf("the kept fence outlived its ACK: %d", fence) |
| + } |
| + }) |
| +} |
diff --git a/internal/activator/replicadeploy.go b/internal/activator/replicadeploy.go| index 548559f7e..bc5363083 100644 |
| --- a/internal/activator/replicadeploy.go |
| +++ b/internal/activator/replicadeploy.go |
| @@ -451,7 +451,9 @@ var replicaRestartBound = residentPoll + workerStartBound |
| // |
| // The bound counts from the first step that finds it so, and holds while |
| // the copy's cold wakes keep failing; any awake generation resets it |
| -// (ReplicaSwap). Past it, the answer is switched, failed, once the stop is |
| +// (ReplicaSwap). A copy waiting for its configuration or for its build's |
| +// install keeps the step open past it, each up to its own bound (below). |
| +// Past it, the answer is switched, failed, once the stop is |
| // proven (below): the ACK resolves the permit and halts the |
| // deploy, and a retry, a fix build or a rollback can begin. decided is |
| // false when the evidence does not hold: the step goes on. |
| @@ -467,7 +469,7 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| return SwapResult{}, false |
| } |
| a.mu.Lock() |
| - for _, why := range []string{keptSecrets, keptConfig} { |
| + for _, why := range []string{keptSecrets, keptConfig, keptInstall} { |
| if a.fences[at.Host] == key.permit && a.fenceOwners[at.Host] == replicaKeptOwner(why, key.id, key.permit) { |
| // Already answered kept for this permit, its fence held since. |
| a.mu.Unlock() |
| @@ -491,9 +493,9 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| // M8) keeps its step open up to releaseConfigBound from its first |
| // such refusal, never switched-failed; past it, it answers kept |
| // (below) with the configuration's reason. |
| - var configSince time.Time |
| + var configSince, installSince time.Time |
| if st := a.residents[at.Host]; st != nil { |
| - configSince = st.configSince |
| + configSince, installSince = st.configSince, st.installSince |
| } |
| if !configSince.IsZero() && a.now().Before(configSince.Add(releaseConfigBound)) { |
| a.mu.Unlock() |
| @@ -501,6 +503,17 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| res.Reason = "this copy holds the permit and waits for its configuration; the step stays open" |
| return res, true |
| } |
| + // A copy whose wakes are refused because no build is installed on its |
| + // box yet (#1061: a join onto a fresh box, root's install not stamped) |
| + // keeps its step open likewise, up to releaseInstallBound from its |
| + // first such refusal; past it, it answers kept with the install's |
| + // reason, so the ACK halts the join without blaming the build. |
| + if !installSince.IsZero() && a.now().Before(installSince.Add(releaseInstallBound)) { |
| + a.mu.Unlock() |
| + res := abandon(errSwapNotAwake) |
| + res.Reason = "this copy holds the permit and waits for its build to be installed; the step stays open" |
| + return res, true |
| + } |
| a.mu.Unlock() |
| if !past { |
| res := abandon(errSwapNotAwake) |
| @@ -524,6 +537,8 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| why = keptSecrets |
| case st != nil && !st.configSince.IsZero(): |
| why = keptConfig |
| + case st != nil && !st.installSince.IsZero(): |
| + why = keptInstall |
| } |
| a.mu.Unlock() |
| owner := fmt.Sprintf("replica-restart:%s:%d", key.id, key.permit) |
| @@ -548,7 +563,8 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| if why != "" { |
| // Its wakes were refused for the instance's shared secrets (a |
| // joining copy whose escrow is not complete; #511 drill 1, R21), |
| - // or for its configuration past releaseConfigBound (round 2): the |
| + // or for its configuration past releaseConfigBound (round 2), or |
| + // for its build's install past releaseInstallBound (#1061): the |
| // target never started here. The answer is kept, not switched, so |
| // the ACK resolves the permit and halts the deploy, and this copy |
| // is not left allowed a build it cannot start. |
| @@ -560,13 +576,21 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| // replicaKeptFencePrefix owns the fence of a kept answer (replicaKeptOwner). |
| const replicaKeptFencePrefix = "replica-kept:" |
| -// Why a permitted step answered kept: the shared secrets, or the |
| -// configuration (round 2). |
| +// Why a permitted step answered kept: the shared secrets, the |
| +// configuration (round 2), or the build's install (#1061). |
| const ( |
| keptSecrets = "secrets" |
| keptConfig = "config" |
| + keptInstall = "install" |
| ) |
| +// releaseInstallBound is how long a joining copy's permitted step waits, |
| +// from its first wake refused because no build is installed on its box |
| +// yet, before it answers kept (#1061): an image download onto a fresh box |
| +// plus the agent's stage-request retries. Past it the join halts and the |
| +// existing copies keep serving; it is never answered switched. |
| +var releaseInstallBound = 10 * time.Minute |
| + |
| // replicaKeptOwner is the owner of the kept answer's fence, for why, for |
| // permit of attempt id. |
| func replicaKeptOwner(why, id string, permit uint64) string { |
| @@ -575,14 +599,18 @@ func replicaKeptOwner(why, id string, permit uint64) string { |
| // replicaKeptFor reports whether owner is a kept fence of permit of id. |
| func replicaKeptFor(owner, id string, permit uint64) bool { |
| - return owner == replicaKeptOwner(keptSecrets, id, permit) || owner == replicaKeptOwner(keptConfig, id, permit) |
| + return owner == replicaKeptOwner(keptSecrets, id, permit) || owner == replicaKeptOwner(keptConfig, id, permit) || |
| + owner == replicaKeptOwner(keptInstall, id, permit) |
| } |
| // replicaKeptAnswer is a permitted step's proven kept answer, for why. |
| func replicaKeptAnswer(why string) SwapResult { |
| reason := replicaSecretsRefusal |
| - if why == keptConfig { |
| + switch why { |
| + case keptConfig: |
| reason = replicaConfigRefusal |
| + case keptInstall: |
| + reason = replicaInstallRefusal |
| } |
| return SwapResult{Outcome: SwapAbandoned, Proven: true, Reason: reason} |
| } |
| @@ -592,6 +620,11 @@ func replicaKeptAnswer(why string) SwapResult { |
| // releaseConfigBound (round 2). copy SR-4-C92 |
| const replicaConfigRefusal = "the new copy's configuration was not written on its box in time, so it did not start. existing copies keep serving" |
| +// replicaInstallRefusal is the kept answer of a copy that never started |
| +// because no build was installed for it on its box within |
| +// releaseInstallBound (#1061). copy SR-6-C01 |
| +const replicaInstallRefusal = "the new copy's build was not installed on its box in time, so it did not start. existing copies keep serving" |
| + |
| // replicaSecretsRefusal is the answer of a copy that never started for |
| // want of the instance's shared secrets: its permitted step's, which halts |
| // the deploy, and, past replicaRestartBound, its wakes' (secretsRefusal). |
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go| index a27220cc6..ca7458eb8 100644 |
| --- a/internal/activator/rootfs_service.go |
| +++ b/internal/activator/rootfs_service.go |
| @@ -435,6 +435,12 @@ type residentState struct { |
| // copy's permitted step keeps its step open for releaseConfigBound |
| // from it (replicaRestartedFailure; round 2). |
| configSince time.Time |
| + // installSince: since when its wakes, the last one included, have been |
| + // refused because no build is installed for it on this box yet |
| + // (errBuildNotInstalled); zero otherwise, and so after any wake that |
| + // served. A copy's permitted step keeps its step open for |
| + // releaseInstallBound from it (replicaRestartedFailure; #1061). |
| + installSince time.Time |
| } |
| // errResidentBackoff is begin's answer for a resident inside its backoff: |
| @@ -473,6 +479,9 @@ func retryAfterSeconds(d time.Duration) int { |
| // classifyRelease reads it as the build's failure (a *ReleaseError): an |
| // unproven unit holds the host as errWakeUnproven does, and a lease end, a |
| // vanished unit or one with no exit recorded is not the build's (INV-R3). |
| +// Nor is a wake the planner refused because no build is installed for the |
| +// instance on this box yet (errBuildNotInstalled, #1061): that waits for |
| +// root's install, and the next tick after the stamp starts it. |
| func residentFailure(err error) bool { |
| switch { |
| case err == nil: |
| @@ -480,7 +489,7 @@ func residentFailure(err error) bool { |
| case isReleaseResult(err): |
| return classifyRelease(err, false) == releaseFailed |
| case errors.Is(err, ErrFenced), errors.Is(err, errShuttingDown), errors.Is(err, context.Canceled), |
| - errors.Is(err, errSwapBusy), errors.Is(err, errWakeUnproven): |
| + errors.Is(err, errSwapBusy), errors.Is(err, errWakeUnproven), errors.Is(err, errBuildNotInstalled): |
| return false |
| } |
| switch verdictOf(err) { |
| @@ -1105,6 +1114,12 @@ func (a *Service) noteResidentWakeLocked(e *actEntry, err error) { |
| case st.configSince.IsZero(): |
| st.configSince = a.now() |
| } |
| + switch { |
| + case !errors.Is(err, errBuildNotInstalled): |
| + st.installSince = time.Time{} |
| + case st.installSince.IsZero(): |
| + st.installSince = a.now() |
| + } |
| } |
| if err == nil || !e.route.Resident() { |
| return |
diff --git a/internal/activator/wakeplan.go b/internal/activator/wakeplan.go| index 01ef24ef1..099288957 100644 |
| --- a/internal/activator/wakeplan.go |
| +++ b/internal/activator/wakeplan.go |
| @@ -33,6 +33,13 @@ type WakePlan struct { |
| Fallback *release.StagedIdentity |
| // Refuse, when set, fails the wake before the lease with this reason. |
| Refuse string |
| + // Installing marks a Refuse that means no build is installed for this |
| + // instance on this box yet (root's stamp has not landed): the wake is |
| + // refused as errBuildNotInstalled, which is no crash of the build |
| + // (residentFailure), and a joining copy's permitted step waits for it |
| + // up to releaseInstallBound (replicaRestartedFailure; #1061). Only the |
| + // planner sets it, with Refuse; nothing compares refusal texts. |
| + Installing bool |
| // FailedUnder is the PromotedAt of the pointer Boot was promoted under, |
| // read by the planner before the wake runs, so a failed first wake is |
| // published with no blocking read (spec §8.1), as dispatch.FailedUnder |
| @@ -65,6 +72,28 @@ type WakePlan struct { |
| func (p WakePlan) planned() bool { return p.Boot.StagedPath != "" } |
| +// errBuildNotInstalled matches a wake the planner refused because no build |
| +// is installed for the instance on this box yet (WakePlan.Installing): a |
| +// wait for root's install, not a failure of any build (#1061). |
| +var errBuildNotInstalled = errors.New("activator: no build is installed for this instance yet") |
| + |
| +// installRefusal is a planner's Installing refusal: its text is the |
| +// plan's Refuse, unchanged, and errors.Is matches errBuildNotInstalled. |
| +type installRefusal struct{ text string } |
| + |
| +func (e installRefusal) Error() string { return e.text } |
| +func (e installRefusal) Is(target error) bool { return target == errBuildNotInstalled } |
| + |
| +// planRefusal is the wake error of plan, a refused plan for host: the |
| +// refusal's text, typed errBuildNotInstalled when the planner marked it |
| +// Installing. |
| +func planRefusal(host string, plan WakePlan) error { |
| + if plan.Installing { |
| + return fmt.Errorf("%s: refusing to wake: %w", host, installRefusal{plan.Refuse}) |
| + } |
| + return fmt.Errorf("%s: refusing to wake: %s", host, plan.Refuse) |
| +} |
| + |
| // errPlanStale: the planned build is no longer the one to boot. A |
| // supersession (gateSuperseded), so it records nothing and falls back to |
| // nothing (classifyStep's stepStale). |
diff --git a/internal/rollout/wakeplan.go b/internal/rollout/wakeplan.go| index a0a964241..c0576ef05 100644 |
| --- a/internal/rollout/wakeplan.go |
| +++ b/internal/rollout/wakeplan.go |
| @@ -72,7 +72,7 @@ func decideWake(in wakeInputs) (activator.WakePlan, error) { |
| if installed == "" { |
| // Plan installs a cold host first; a plan for a host with nothing |
| // installed refuses rather than let the live link run unplanned. |
| - return activator.WakePlan{Refuse: "no build is installed for this instance yet"}, nil |
| + return notInstalledPlan(), nil |
| } |
| hasGood := rt.GoodVersion != "" && rt.GoodDigest != "" |
| good := release.StagedIdentity{Version: rt.GoodVersion, StagedPath: release.VersionPath(in.OptDir, acct, rt.GoodVersion, app), |
| @@ -281,7 +281,7 @@ func (m *Manager) Plan(ctx context.Context, rt registry.Route) (plan activator.W |
| // Nothing managed ever runs through an empty plan: the live-link |
| // wake would materialize the channel head and exec it unplanned. |
| if m.d.Materialize == nil { |
| - return activator.WakePlan{Refuse: "no build is installed for this instance yet"} |
| + return notInstalledPlan() |
| } |
| if err := m.d.Materialize(ctx, rt.Host); err != nil { |
| m.d.Logf("rollout: %s: install before its wake: %v", rt.Host, err) |
| @@ -292,7 +292,7 @@ func (m *Manager) Plan(ctx context.Context, rt registry.Route) (plan activator.W |
| if err != nil { |
| m.d.Logf("rollout: %s: read the row after its install: %v", rt.Host, err) |
| } |
| - return activator.WakePlan{Refuse: "no build is installed for this instance yet"} |
| + return notInstalledPlan() |
| } |
| rt = *fresh |
| } |
| @@ -306,20 +306,34 @@ func (m *Manager) Plan(ctx context.Context, rt registry.Route) (plan activator.W |
| if err != nil { |
| m.d.Logf("rollout: %s: read the row after its plan: %v", rt.Host, err) |
| } |
| - return activator.WakePlan{Refuse: "no build is installed for this instance yet"} |
| + return notInstalledPlan() |
| } |
| if fresh.Version == rt.Version { |
| return plan |
| } |
| if again { |
| m.d.Logf("rollout: %s: its installed build moved twice while its wake was planned (%s, now %s); refusing the wake", rt.Host, rt.Version, fresh.Version) |
| - return activator.WakePlan{Refuse: "no build is installed for this instance yet"} |
| + return notInstalledPlan() |
| } |
| m.d.Logf("rollout: %s: its installed build moved from %s to %s while its wake was planned; planning again", rt.Host, rt.Version, fresh.Version) |
| rt = *fresh |
| } |
| } |
| +// notInstalledRefusal is a wake's refusal while no build is installed for |
| +// the instance on this box yet: its row has no installed build, the row |
| +// could not be read, or its install was still landing while the wake was |
| +// planned. |
| +const notInstalledRefusal = "no build is installed for this instance yet" |
| + |
| +// notInstalledPlan is notInstalledRefusal's plan, marked Installing so the |
| +// activator types it (errBuildNotInstalled): a wait for root's install, not |
| +// a failure of the build, which a joining copy's permitted step waits for |
| +// within its bound (#1061). |
| +func notInstalledPlan() activator.WakePlan { |
| + return activator.WakePlan{Refuse: notInstalledRefusal, Installing: true} |
| +} |
| + |
| // movingRefusal is a wake's refusal while the instance's attempt has not |
| // reported (Plan's attemptRunning check, and beginWake meeting the |
| // attempt's intent between its slot freeing and its End). |
diff --git a/internal/rollout/wakeplan_test.go b/internal/rollout/wakeplan_test.go| index e0ced1eba..c48c71508 100644 |
| --- a/internal/rollout/wakeplan_test.go |
| +++ b/internal/rollout/wakeplan_test.go |
| @@ -838,3 +838,78 @@ func TestAPlanInItsSlowReadsKeepsItsBuildsFailureRecord(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// TestNotInstalledRefusalsAreMarkedInstalling (#1061): every refusal that |
| +// means no build is installed for the instance on this box yet carries |
| +// WakePlan.Installing, so the activator types it (a wait for root's |
| +// install, never a crash) without reading its text. Other refusals do not. |
| +func TestNotInstalledRefusalsAreMarkedInstalling(t *testing.T) { |
| + installing := func(t *testing.T, site string, p activator.WakePlan) { |
| + t.Helper() |
| + if p.Refuse != "no build is installed for this instance yet" || !p.Installing || p.Boot.StagedPath != "" { |
| + t.Fatalf("%s: plan %+v, want the not-installed refusal marked Installing", site, p) |
| + } |
| + } |
| + cold := func(h *harness) { |
| + r := h.rows.get("a") |
| + r.Version = "" |
| + h.rows.put(r) |
| + } |
| + t.Run("decideWake: nothing installed", func(t *testing.T) { |
| + p, _ := decideWake(inputs(wakeRoute("", ""), &FailureBook{}, DefaultPolicy())) |
| + installing(t, "decideWake", p) |
| + }) |
| + t.Run("Plan: cold, no installer", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + cold(h) |
| + h.m.d.Materialize = nil |
| + installing(t, "no Materialize", h.m.Plan(context.Background(), h.rows.get("a"))) |
| + }) |
| + t.Run("Plan: cold, the install left nothing installed", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + cold(h) |
| + h.m.d.Materialize = func(context.Context, string) error { return nil } |
| + installing(t, "row empty after install", h.m.Plan(context.Background(), h.rows.get("a"))) |
| + }) |
| + t.Run("Plan: the row cannot be read after its plan", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + h.stage("v2") |
| + h.install("v2", "a") |
| + rt := h.rows.get("a") |
| + h.rows.mu.Lock() |
| + h.rows.getErr = func(string) error { return errors.New("registry: disk I/O error") } |
| + h.rows.mu.Unlock() |
| + installing(t, "row unreadable after plan", h.m.Plan(context.Background(), rt)) |
| + }) |
| + t.Run("Plan: the row moves twice", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + h.stage("v2", "v3", "v4") |
| + h.install("v2", "a") |
| + h.wakeHost("a") |
| + blocked, release := h.blockDemand("v2") |
| + defer release() |
| + done := h.planAsync(h.rows.get("a")) |
| + waitClosed(t, "Plan to read v2's demand", blocked) |
| + h.install("v3", "a") |
| + blocked3, release3 := h.blockDemand("v3") |
| + defer release3() |
| + release() |
| + waitClosed(t, "the replan to read v3's demand", blocked3) |
| + h.install("v4", "a") |
| + release3() |
| + installing(t, "moved twice", <-done) |
| + }) |
| + t.Run("other refusals are not marked", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + cold(h) |
| + h.m.d.Materialize = func(context.Context, string) error { return errors.New("no space left on device") } |
| + if p := h.m.Plan(context.Background(), h.rows.get("a")); p.Refuse == "" || p.Installing { |
| + t.Fatalf("a failed install: plan %+v, want refused and not marked Installing", p) |
| + } |
| + down := &FailureBook{} |
| + down.Record(FailureRecord{Account: "bab", App: "blog", Build: "v2", Host: "a", HeldDown: []string{"a"}, At: t0}) |
| + if p, _ := decideWake(inputs(wakeRoute("v2", "v1"), down, DefaultPolicy())); p.Refuse == "" || p.Installing { |
| + t.Fatalf("a held-down build: plan %+v, want refused and not marked Installing", p) |
| + } |
| + }) |
| +} |