activator: one install deadline; outages are not installs (#1061 r1)
Fix round 1 for Task 1 (Astra P1, P2). P1: installSince is now one deadline for the whole wait, scoped to the row lifetime (ReplicaIncarnation). A refusal that ran nothing (the moving refusal, now typed WakePlan.Moving / errInstanceMoving, a fence, an ownership end) keeps it; only a wake that served, a failure of the build (residentFailure) or another lifetime clears it. The moving refusal is no longer counted as a crash. A step past replicaRestartBound with a moving refusal last stays open, never switched-failed. P2: only a row read with no installed build is marked Installing. A row that could not be read or was gone (after the install or the plan), or that moved twice, keeps the same words unmarked, so a registry outage keeps its crash backoff.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/activator/replica_install_wait_test.go+123 −0internal/activator/replicadeploy.go+5 −2internal/activator/rootfs_service.go+41 −13internal/activator/wakeplan.go+23 −8internal/rollout/intent_test.go+2 −2internal/rollout/wakeplan.go+38 −13internal/rollout/wakeplan_test.go+36 −6
Intent
<task-notification> <task-id>a9fd60e14bb47d1b0</task-id> <tool-use-id>toolu_015qn3fzixZU8g298gZPEkPz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/a9fd60e14bb47d1b0.output</output-file> <status>completed</status> <summary>Agent "Implement #1061 Task 1" 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>Status: DONE_WITH_CONCERNS Commit: `882a3f34 activator: a join waits for its build install; not a crash (#1061)` Tests: W1 (`TestJoinInstallWaitKeepsStepOpen`) failed on the old code in three ways: the refusal wasn't typed, it was counted as a crash (backoff 1 s), and past 32 s the step answered switched with WebFailed. It passes now. The new rollout test covering all five planner refusals also passes, and fails if the marker is removed. The full activator and rollout packages pass. The whole repo builds, and both packages build for darwin and windows. All five refusal sites are the same "no build is installed" refusal, so all five are marked. The "still moving to another build" refusal and the other refusals are not. Concerns: 1. The stateless replicas spec has no §25 or §7.5, so I read §6.4 and §7 instead. If another spec was meant, the change hasn't been checked against it. 2. The install wait's start time resets like the config wait's: another refusal landing between install refusals (e.g. "still moving") restarts it. That makes the 10-minute limit slightly soft, but the step still can't be answered switched-failed. 3. The census note (census-proposal-stateless-replicas-4-drill1.md) has a row for `replicaRestartedFailure` that may need updating; ask the census reviewer. 4. The "waits for its build to be installed" reason while the step stays open has no copy tag, matching the config wait's reason. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/sr-followups/.superpowers/sdd/plan-1061/task-1-report.md</result> <usage><subagent_tokens>132838</subagent_tokens><tool_uses>50</tool_uses><duration_ms>784774</duration_ms></usage> </task-notification>
<task-notification> <task-id>baqviq1kh</task-id> <tool-use-id>toolu_01WiadE4M3EfJkyt1BDXADz6</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/baqviq1kh.output</output-file> <status>completed</status> <summary>Background command "P=.superpowers/sdd/plan-1061 && cat > $P/task-1-astra-brief.md <<'EOF' You are reviewing one task of a Go change in the CARLOS platform, read-only. Do not modify files, the index or branch state. Read: 1. Task brief (requirements): .superpowers/sdd/plan-1061/task-1-brief.md 2. Global Constraints section only of .superpowers/sdd/2026-11-14-sr-followups/plan-1061.md 3. Background: .superpowers/sdd/2026-11-14-sr-followups/1061-investigation.md sections 3, 4, 6 4. The implemente ... [1649 characters truncated] ... a suggested fix. Be concise. EOF timeout 1800 codex exec -m gpt-6-astra -c model_reasoning_effort=high -s read-only "Read .superpowers/sdd/plan-1061/task-1-astra-brief.md and do what it says." </dev/null > $P/task-1-astra-review.txt 2>&1; tail -60 $P/task-1-astra-review.txt" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 9.00 g CO₂e (1,021,005 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/internal/activator/replica_install_wait_test.go b/internal/activator/replica_install_wait_test.go| index ef3203f8b..5d6aaef30 100644 |
| --- a/internal/activator/replica_install_wait_test.go |
| +++ b/internal/activator/replica_install_wait_test.go |
| @@ -3,10 +3,12 @@ package activator |
| import ( |
| "context" |
| "errors" |
| + "fmt" |
| "slices" |
| "testing" |
| "time" |
| + "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/replicas" |
| ) |
| @@ -101,6 +103,68 @@ func TestJoinInstallWaitKeepsStepOpen(t *testing.T) { |
| t.Fatalf("the joined copy's switch was not proven: %+v", res) |
| } |
| }) |
| + // #1061 fix round 1, P1: a moving refusal (an attempt in flight) ran |
| + // nothing, so it neither grows the backoff nor restarts the install |
| + // deadline. A step after replicaRestartBound whose last wake was a |
| + // moving refusal stays open, and install, moving, install ... runs to |
| + // one deadline from the first install refusal, then kept. |
| + moving := WakePlan{Refuse: "this instance is still moving to another build", Moving: true, Token: 4} |
| + movingWake := func(t *testing.T, r *replicaSetRig, wake func() error, when string) { |
| + t.Helper() |
| + r.setPlan(moving) |
| + err := wake() |
| + r.setPlan(notInstalled) |
| + if !errors.Is(err, errInstanceMoving) || errors.Is(err, errBuildNotInstalled) { |
| + t.Fatalf("%s: the wake was not refused as moving: %v", when, err) |
| + } |
| + if want := r.rt.Host + ": refusing to wake: this instance is still moving to another build"; err.Error() != want { |
| + t.Fatalf("%s: the refusal's text changed: %q", when, err.Error()) |
| + } |
| + r.a.mu.Lock() |
| + failures, retryAt := r.a.residents[r.rt.Host].failures, r.a.residents[r.rt.Host].retryAt |
| + now := r.a.now() |
| + r.a.mu.Unlock() |
| + if failures != 0 || retryAt.After(now) { |
| + t.Fatalf("%s: the moving refusal was counted as a crash: failures %d", when, failures) |
| + } |
| + } |
| + since := func(r *replicaSetRig) time.Time { |
| + r.a.mu.Lock() |
| + defer r.a.mu.Unlock() |
| + return r.a.residents[r.rt.Host].installSince |
| + } |
| + t.Run("moving refusal last, past replicaRestartBound", func(t *testing.T) { |
| + r, wake, step := setup(t) |
| + refused(t, r, wake, "first wake") |
| + first := since(r) |
| + open(t, step(false), "at once") |
| + r.clk.advance(40 * time.Second) |
| + movingWake(t, r, wake, "moving at 40s") |
| + if got := since(r); !got.Equal(first) { |
| + t.Fatalf("the moving refusal moved the install deadline: %s, want %s", got, first) |
| + } |
| + open(t, step(false), "past replicaRestartBound, a moving refusal last") |
| + }) |
| + t.Run("install, moving, install keeps one deadline", func(t *testing.T) { |
| + r, wake, step := setup(t) |
| + refused(t, r, wake, "first wake") |
| + first := since(r) |
| + for gone := time.Duration(0); gone+50*time.Second < releaseInstallBound; gone += 50 * time.Second { |
| + r.clk.advance(25 * time.Second) |
| + movingWake(t, r, wake, "moving") |
| + r.clk.advance(25 * time.Second) |
| + refused(t, r, wake, "install") |
| + if got := since(r); !got.Equal(first) { |
| + t.Fatalf("after %s the install deadline restarted: %s, want %s", gone+50*time.Second, got, first) |
| + } |
| + open(t, step(false), "within the bound") |
| + } |
| + r.clk.advance(releaseInstallBound) |
| + movingWake(t, r, wake, "moving past the bound") |
| + if res := step(false); !res.Proven || res.WebFailed || res.Reason != replicaInstallRefusal { |
| + t.Fatalf("past the one deadline, not answered kept for the install: %+v", res) |
| + } |
| + }) |
| t.Run("never installed", func(t *testing.T) { |
| r, wake, step := setup(t) |
| refused(t, r, wake, "first wake") |
| @@ -136,3 +200,62 @@ func TestJoinInstallWaitKeepsStepOpen(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// TestInstallWaitDeadlineRules (#1061 fix round 1, P1): the install wait's |
| +// deadline is kept across refusals that ran nothing and cleared by a wake |
| +// that served, a failure of the build, or another row lifetime. |
| +func TestInstallWaitDeadlineRules(t *testing.T) { |
| + r := newWakeRelRig(t) |
| + rt := r.rt |
| + rt.Hibernate = false |
| + rt.ReplicaIncarnation = "inc-1" |
| + notInstalled := fmt.Errorf("%s: refusing to wake: %w", rt.Host, typedRefusal{"no build is installed for this instance yet", errBuildNotInstalled}) |
| + moving := fmt.Errorf("%s: refusing to wake: %w", rt.Host, typedRefusal{"this instance is still moving to another build", errInstanceMoving}) |
| + note := func(rt registry.Route, err error) (time.Time, int) { |
| + r.a.mu.Lock() |
| + defer r.a.mu.Unlock() |
| + r.a.noteResidentWakeLocked(&actEntry{host: rt.Host, route: rt}, err) |
| + st := r.a.residents[rt.Host] |
| + return st.installSince, st.failures |
| + } |
| + start := r.clk.now() |
| + if got, _ := note(rt, notInstalled); !got.Equal(start) { |
| + t.Fatalf("the first install refusal did not start the deadline: %s", got) |
| + } |
| + r.clk.advance(time.Minute) |
| + for _, err := range []error{moving, ErrFenced, notInstalled} { |
| + if got, failures := note(rt, err); !got.Equal(start) || failures != 0 { |
| + t.Fatalf("%v moved the deadline to %s (failures %d), want %s kept", err, got, failures, start) |
| + } |
| + } |
| + if got, failures := note(rt, errors.New("the web process exited at start")); !got.IsZero() || failures != 1 { |
| + t.Fatalf("a failure of the build kept the deadline %s (failures %d); a crash stays a crash", got, failures) |
| + } |
| + r.clk.advance(time.Minute) |
| + restart := r.clk.now() |
| + note(rt, notInstalled) |
| + if got, _ := note(rt, nil); !got.IsZero() { |
| + t.Fatalf("a wake that served kept the deadline %s", got) |
| + } |
| + note(rt, notInstalled) |
| + other := rt |
| + other.ReplicaIncarnation = "inc-2" |
| + if got, _ := note(other, moving); !got.IsZero() { |
| + t.Fatalf("another row lifetime kept the deadline %s", got) |
| + } |
| + r.clk.advance(time.Minute) |
| + note(rt, notInstalled) |
| + if got, _ := note(other, notInstalled); !got.Equal(r.clk.now()) || got.Equal(restart) { |
| + t.Fatalf("another row lifetime's install refusal did not start its own deadline: %s", got) |
| + } |
| + // Fix round 1, P2: the same words unmarked (a row the planner could |
| + // not read) are no install wait: planRefusal leaves them untyped, they |
| + // count toward the backoff and they clear the deadline. |
| + unconfirmed := planRefusal(other.Host, WakePlan{Refuse: "no build is installed for this instance yet"}) |
| + if errors.Is(unconfirmed, errBuildNotInstalled) || !residentFailure(unconfirmed) { |
| + t.Fatalf("an unmarked refusal was typed as an install wait: %v", unconfirmed) |
| + } |
| + if got, failures := note(other, unconfirmed); !got.IsZero() || failures == 0 { |
| + t.Fatalf("an unconfirmed install kept the deadline %s or set no backoff (failures %d)", got, failures) |
| + } |
| +} |
diff --git a/internal/activator/replicadeploy.go b/internal/activator/replicadeploy.go| index bc5363083..cb3e846a0 100644 |
| --- a/internal/activator/replicadeploy.go |
| +++ b/internal/activator/replicadeploy.go |
| @@ -495,7 +495,10 @@ func (a *Service) replicaRestartedFailure(ctx context.Context, at Attempt, deplo |
| // (below) with the configuration's reason. |
| var configSince, installSince time.Time |
| if st := a.residents[at.Host]; st != nil { |
| - configSince, installSince = st.configSince, st.installSince |
| + configSince = st.configSince |
| + if st.installFor == deploy.Incarnation { |
| + installSince = st.installSince |
| + } |
| } |
| if !configSince.IsZero() && a.now().Before(configSince.Add(releaseConfigBound)) { |
| a.mu.Unlock() |
| @@ -537,7 +540,7 @@ 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(): |
| + case st != nil && !st.installSince.IsZero() && st.installFor == deploy.Incarnation: |
| why = keptInstall |
| } |
| a.mu.Unlock() |
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go| index ca7458eb8..d080af6ca 100644 |
| --- a/internal/activator/rootfs_service.go |
| +++ b/internal/activator/rootfs_service.go |
| @@ -435,12 +435,17 @@ 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: the first wake refused because no build is installed |
| + // for it on this box yet (errBuildNotInstalled), for the row lifetime |
| + // installFor (its ReplicaIncarnation); zero otherwise. It is one |
| + // deadline for the whole wait (#1061 fix round 1, P1): a refusal that |
| + // ran nothing in between (the moving refusal, a fence, an ownership |
| + // end) keeps it; only a wake that served, a failure of the build |
| + // (residentFailure) or another row lifetime clears it. A copy's |
| + // permitted step keeps its step open for releaseInstallBound from it |
| + // (replicaRestartedFailure; #1061). |
| installSince time.Time |
| + installFor string |
| } |
| // errResidentBackoff is begin's answer for a resident inside its backoff: |
| @@ -481,7 +486,9 @@ func retryAfterSeconds(d time.Duration) int { |
| // 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. |
| +// root's install, and the next tick after the stamp starts it. Nor a wake |
| +// refused while the instance's attempt has not reported |
| +// (errInstanceMoving): nothing ran (#1061 fix round 1). |
| func residentFailure(err error) bool { |
| switch { |
| case err == nil: |
| @@ -489,7 +496,8 @@ 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, errBuildNotInstalled): |
| + errors.Is(err, errSwapBusy), errors.Is(err, errWakeUnproven), errors.Is(err, errBuildNotInstalled), |
| + errors.Is(err, errInstanceMoving): |
| return false |
| } |
| switch verdictOf(err) { |
| @@ -1114,12 +1122,7 @@ 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() |
| - } |
| + a.noteInstallWaitLocked(st, e.route, err) |
| } |
| if err == nil || !e.route.Resident() { |
| return |
| @@ -1137,6 +1140,31 @@ func (a *Service) noteResidentWakeLocked(e *actEntry, err error) { |
| st.retryAt = now.Add(residentBackoff(st.failures, a.residentJitterLocked())) |
| } |
| +// noteInstallWaitLocked keeps st.installSince, the install wait's one |
| +// deadline (#1061 fix round 1, P1), for a wake of rt that ended with err: |
| +// - a wake that served, or a failure of the build (residentFailure: a |
| +// crash, a health failure, anything unclassified, a registry outage |
| +// included) clears it, so a crash stays a failure; |
| +// - a refusal for no installed build starts it, unless one has already |
| +// started for this row lifetime; |
| +// - a wake of another row lifetime (ReplicaIncarnation) clears it; |
| +// - any other refusal ran nothing (the moving refusal, a fence, an |
| +// ownership end, the configuration's wait) and keeps it. |
| +// |
| +// The caller holds a.mu. |
| +func (a *Service) noteInstallWaitLocked(st *residentState, rt registry.Route, err error) { |
| + switch { |
| + case err == nil || residentFailure(err): |
| + st.installSince, st.installFor = time.Time{}, "" |
| + case errors.Is(err, errBuildNotInstalled): |
| + if st.installSince.IsZero() || st.installFor != rt.ReplicaIncarnation { |
| + st.installSince, st.installFor = a.now(), rt.ReplicaIncarnation |
| + } |
| + case st.installFor != rt.ReplicaIncarnation: |
| + st.installSince, st.installFor = time.Time{}, "" |
| + } |
| +} |
| + |
| // noteResidentStopLocked is a stop's outcome for residency, in finishStop as |
| // the entry is forgotten. A crash (StopExited) or a lost lease |
| // (StopLeaseLost) is a failure: a run of residentHealthyRun or more resets |
diff --git a/internal/activator/wakeplan.go b/internal/activator/wakeplan.go| index 099288957..c0fb725cc 100644 |
| --- a/internal/activator/wakeplan.go |
| +++ b/internal/activator/wakeplan.go |
| @@ -40,6 +40,11 @@ type WakePlan struct { |
| // up to releaseInstallBound (replicaRestartedFailure; #1061). Only the |
| // planner sets it, with Refuse; nothing compares refusal texts. |
| Installing bool |
| + // Moving marks a Refuse given while the instance's attempt has not |
| + // reported (the rollout planner's moving refusal): nothing ran, so it is |
| + // errInstanceMoving, no crash of the build, and a join's install wait |
| + // (installSince) carries on through it (#1061 fix round 1). |
| + Moving 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 |
| @@ -77,19 +82,29 @@ func (p WakePlan) planned() bool { return p.Boot.StagedPath != "" } |
| // 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 } |
| +// errInstanceMoving matches a wake the planner refused because the |
| +// instance's attempt has not reported yet (WakePlan.Moving): nothing ran. |
| +var errInstanceMoving = errors.New("activator: this instance is still moving to another build") |
| -func (e installRefusal) Error() string { return e.text } |
| -func (e installRefusal) Is(target error) bool { return target == errBuildNotInstalled } |
| +// typedRefusal is a planner's typed refusal: its text is the plan's |
| +// Refuse, unchanged, and errors.Is matches its kind. |
| +type typedRefusal struct { |
| + text string |
| + kind error |
| +} |
| + |
| +func (e typedRefusal) Error() string { return e.text } |
| +func (e typedRefusal) Is(target error) bool { return target == e.kind } |
| // planRefusal is the wake error of plan, a refused plan for host: the |
| // refusal's text, typed errBuildNotInstalled when the planner marked it |
| -// Installing. |
| +// Installing and errInstanceMoving when it marked it Moving. |
| func planRefusal(host string, plan WakePlan) error { |
| - if plan.Installing { |
| - return fmt.Errorf("%s: refusing to wake: %w", host, installRefusal{plan.Refuse}) |
| + switch { |
| + case plan.Installing: |
| + return fmt.Errorf("%s: refusing to wake: %w", host, typedRefusal{plan.Refuse, errBuildNotInstalled}) |
| + case plan.Moving: |
| + return fmt.Errorf("%s: refusing to wake: %w", host, typedRefusal{plan.Refuse, errInstanceMoving}) |
| } |
| return fmt.Errorf("%s: refusing to wake: %s", host, plan.Refuse) |
| } |
diff --git a/internal/rollout/intent_test.go b/internal/rollout/intent_test.go| index 73e9cea50..ed07826ec 100644 |
| --- a/internal/rollout/intent_test.go |
| +++ b/internal/rollout/intent_test.go |
| @@ -440,8 +440,8 @@ func TestAFirstWakeNeverReplacesAnAttemptsIntent(t *testing.T) { |
| t.Fatal(err) |
| } |
| p := h.m.Plan(context.Background(), h.rows.get("a")) |
| - if p.Refuse != "this instance is still moving to another build" { |
| - t.Fatalf("plan %+v: want the moving refusal", p) |
| + if p.Refuse != "this instance is still moving to another build" || !p.Moving || p.Installing { |
| + t.Fatalf("plan %+v: want the moving refusal, marked Moving (#1061)", p) |
| } |
| if in := h.book.intents["a"]; in.ID != "a1" { |
| t.Fatalf("intent %+v: the attempt's was replaced", in) |
diff --git a/internal/rollout/wakeplan.go b/internal/rollout/wakeplan.go| index c0576ef05..693892008 100644 |
| --- a/internal/rollout/wakeplan.go |
| +++ b/internal/rollout/wakeplan.go |
| @@ -272,7 +272,7 @@ func (m *Manager) Plan(ctx context.Context, rt registry.Route) (plan activator.W |
| // hold that went down, or a swap whose entry stopped under it, is |
| // recorded by done() before anything wakes the instance, so no wake |
| // can boot the good build ahead of a hold-down record. |
| - return activator.WakePlan{Refuse: movingRefusal} |
| + return movingPlan() |
| } |
| if rt.Version == "" { |
| // A cold managed host (spec §6.4, §8.4): its build is installed and |
| @@ -288,10 +288,16 @@ func (m *Manager) Plan(ctx context.Context, rt registry.Route) (plan activator.W |
| return activator.WakePlan{Refuse: "its build could not be installed"} |
| } |
| fresh, err := m.d.Routes.Get(rt.Host) |
| - if err != nil || fresh == nil || fresh.Version == "" { |
| + if err != nil || fresh == nil { |
| + // The row could not be read: nothing confirms the build is |
| + // missing, so the refusal is not an install wait (#1061 fix |
| + // round 1): a registry outage keeps its backoff. |
| if err != nil { |
| m.d.Logf("rollout: %s: read the row after its install: %v", rt.Host, err) |
| } |
| + return unconfirmedPlan() |
| + } |
| + if fresh.Version == "" { |
| return notInstalledPlan() |
| } |
| rt = *fresh |
| @@ -306,34 +312,51 @@ 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 notInstalledPlan() |
| + return unconfirmedPlan() |
| } |
| 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 notInstalledPlan() |
| + return unconfirmedPlan() |
| } |
| 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. |
| +// notInstalledRefusal is a wake's refusal while no build is confirmed |
| +// installed for the instance on this box: its row, read, has no installed |
| +// build (notInstalledPlan), or its row could not be read or confirmed |
| +// (unconfirmedPlan). The words are the same; only the first is typed. |
| 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). |
| +// notInstalledPlan is notInstalledRefusal's plan for a row read with no |
| +// installed build, 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). Only a confirmed missing install is marked. |
| func notInstalledPlan() activator.WakePlan { |
| return activator.WakePlan{Refuse: notInstalledRefusal, Installing: true} |
| } |
| +// unconfirmedPlan is notInstalledRefusal's plan when the row could not be |
| +// read after an install or a plan, or moved twice during the plan: nothing |
| +// confirms a missing install, so it is not marked (#1061 fix round 1, P2), |
| +// and the activator counts it as it counts any unclassified failure (a |
| +// registry outage backs off). |
| +func unconfirmedPlan() activator.WakePlan { |
| + return activator.WakePlan{Refuse: notInstalledRefusal} |
| +} |
| + |
| +// movingPlan is movingRefusal's plan, marked Moving so the activator types |
| +// it (errInstanceMoving): nothing ran, and a join's install wait carries on |
| +// through it (#1061 fix round 1, P1). |
| +func movingPlan() activator.WakePlan { |
| + return activator.WakePlan{Refuse: movingRefusal, Moving: 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). |
| @@ -364,7 +387,9 @@ func (m *Manager) beginWake(rt registry.Route, plan activator.WakePlan, tok uint |
| if errors.Is(err, ErrIntentStands) { |
| // The instance's attempt finished and has not yet ended its intent: |
| // it is still, for a moment, moving. Not a book fault. |
| - return activator.WakePlan{Refuse: movingRefusal, Token: tok} |
| + plan := movingPlan() |
| + plan.Token = tok |
| + return plan |
| } |
| return activator.WakePlan{Refuse: BookUnreadableRefusal, Token: tok} |
| } |
diff --git a/internal/rollout/wakeplan_test.go b/internal/rollout/wakeplan_test.go| index c48c71508..198356c3a 100644 |
| --- a/internal/rollout/wakeplan_test.go |
| +++ b/internal/rollout/wakeplan_test.go |
| @@ -575,8 +575,8 @@ func TestAForeignRowsFailedHoldIsHeldDown(t *testing.T) { |
| h.pass() |
| waitFor(t, "the attempt to start", func() bool { _, started, _ := h.act.snapshot(); return len(started) == 1 }) |
| // Approved wording (zdd.refuse.attempt-running, zdd.refuse.held-down). |
| - if p := h.m.Plan(context.Background(), h.rows.get("a")); p.Refuse != "this instance is still moving to another build" { |
| - t.Fatalf("a wake was planned while the instance's attempt ran: %+v", p) |
| + if p := h.m.Plan(context.Background(), h.rows.get("a")); p.Refuse != "this instance is still moving to another build" || !p.Moving || p.Installing { |
| + t.Fatalf("a wake was planned while the instance's attempt ran, or its refusal is not marked Moving (#1061): %+v", p) |
| } |
| close(gate) |
| waitFor(t, "the hold-down record", func() bool { return h.book.HeldDown("bab", "blog", "v2", "a") }) |
| @@ -840,9 +840,11 @@ func TestAPlanInItsSlowReadsKeepsItsBuildsFailureRecord(t *testing.T) { |
| } |
| // TestNotInstalledRefusalsAreMarkedInstalling (#1061): every refusal that |
| -// means no build is installed for the instance on this box yet carries |
| +// confirms 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. |
| +// install, never a crash) without reading its text. A row that could not |
| +// be read or confirmed keeps the same words unmarked (fix round 1, P2): |
| +// a registry outage keeps its backoff. Other refusals are not marked. |
| func TestNotInstalledRefusalsAreMarkedInstalling(t *testing.T) { |
| installing := func(t *testing.T, site string, p activator.WakePlan) { |
| t.Helper() |
| @@ -871,6 +873,12 @@ func TestNotInstalledRefusalsAreMarkedInstalling(t *testing.T) { |
| 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"))) |
| }) |
| + unconfirmed := 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.Moving || p.Boot.StagedPath != "" { |
| + t.Fatalf("%s: plan %+v, want the same refusal unmarked: nothing confirms a missing install", site, p) |
| + } |
| + } |
| t.Run("Plan: the row cannot be read after its plan", func(t *testing.T) { |
| h := newHarness(t, "a") |
| h.stage("v2") |
| @@ -879,7 +887,29 @@ func TestNotInstalledRefusalsAreMarkedInstalling(t *testing.T) { |
| 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)) |
| + unconfirmed(t, "row unreadable after plan", h.m.Plan(context.Background(), rt)) |
| + }) |
| + t.Run("Plan: the row cannot be read after a cold install", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + cold(h) |
| + h.m.d.Materialize = func(context.Context, string) error { |
| + h.rows.mu.Lock() |
| + h.rows.getErr = func(string) error { return errors.New("registry: disk I/O error") } |
| + h.rows.mu.Unlock() |
| + return nil |
| + } |
| + unconfirmed(t, "row unreadable after install", h.m.Plan(context.Background(), h.rows.get("a"))) |
| + }) |
| + t.Run("Plan: the row is gone after a cold install", func(t *testing.T) { |
| + h := newHarness(t, "a") |
| + cold(h) |
| + h.m.d.Materialize = func(context.Context, string) error { |
| + h.rows.mu.Lock() |
| + delete(h.rows.rows, "a") |
| + h.rows.mu.Unlock() |
| + return nil |
| + } |
| + unconfirmed(t, "row gone after install", h.m.Plan(context.Background(), registry.Route{Host: "a", Kind: "instance", App: "blog", Account: "bab", Status: "ready", Hibernate: true})) |
| }) |
| t.Run("Plan: the row moves twice", func(t *testing.T) { |
| h := newHarness(t, "a") |
| @@ -897,7 +927,7 @@ func TestNotInstalledRefusalsAreMarkedInstalling(t *testing.T) { |
| waitClosed(t, "the replan to read v3's demand", blocked3) |
| h.install("v4", "a") |
| release3() |
| - installing(t, "moved twice", <-done) |
| + unconfirmed(t, "moved twice", <-done) |
| }) |
| t.Run("other refusals are not marked", func(t *testing.T) { |
| h := newHarness(t, "a") |