Repository navigation
fix(nativeupdate): fall back to the previous release when current is damaged - #1895
Conversation
…damaged Select always ended on Current, so a release with a missing file failed every start. When Current fails its release check, the previous release is healthy and both receipts name the same state schema, run Previous once as a trial and record Current as LastFailed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69eb361da6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tag, trial = previous, true | ||
| path, readErr = m.ReleaseDir(tag) |
There was a problem hiding this comment.
Allow the launcher to execute the newly selected fallback trial
If a pending update fails to exec and the current release is also damaged, this path selects the healthy previous release as a trial, but launch in go/cmd/ftw-launcher/main.go:121–126 explicitly rejects a trial returned by its second Select() call. The launcher exits with fallback selected another trial without executing the previous release. On the next service start, Select() marks that unexecuted trial as failed, permanently suppressing the only healthy fallback. Update the launcher to accept this recovery transition, and cover the pending-update exec-failure scenario with a launcher integration test.
Useful? React with 👍 / 👎.
When a pending update failed to exec while current was damaged, the launcher's second Select returned the previous release as a trial, and launch() refused it. The next start then marked that unrun release as failed, so the box stayed in its restart loop. launch() now execs the fallback as a trial with one attempt and records a failure with FailTrial. The fallback no longer overwrites a LastFailed that is already set, such as a trial that just crashed. Updates would otherwise offer that release again. A fallback that dies still marks the previous release, so it runs only once. Log a warning when the launcher falls back, and say in the changeset that boxes need an installer refresh of ftw-launcher to get this. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Item F4 of the stable plan.
Problem
Manager.Selectalways ends withReleaseDir(state.Current)(slots.go:182-187). If one file in the current release goes missing, for exampleweb/index.htmlafter SD card damage, every start fails withrelease v0.132.0 is incomplete. The launcher exits, systemd restarts it every 5 s, and Core never runs. Probation cannot help: it acts only within one hour of a commit, and its rollback check also requires a healthy current release.ftw-launcher rollbackfails for the same reason. The only fix today is to edit/opt/ftw/slots.jsonby hand.Repro: current v0.132.0, previous v0.131.0, both on schema 7, 48 h after commit. Delete
releases/v0.132.0/web/index.html. On master, five starts in a row fail and the slots stay unchanged.ADR 0007 decision 3 already says the launcher should select
previousoffline under the same schema rule. The code did not.Change
When the current release fails its check and no trial is starting,
Selectnow runs the previous release once as a trial. It does so only when:ReleaseDir;Previous != LastFailed), so a fallback that dies is not retried;If the current receipt is the damaged file, the schema is unknown, so the launcher does not fall back. The trial commits like any other trial, after Core is ready.
rollbackCandidateLockedandPrepareRollbackare unchanged. The launcher logs a warning naming both releases when it falls back.SelectsetsLastFailedto the damaged current release only when nothing is marked yet. A release that already failed, such as a trial that just crashed, stays marked, so the update check does not offer it again. A fallback trial that dies still marks the previous release through the trial branch, so it runs only once.launch()used to refuse a trial from its secondSelect. With a pending update that failed to exec while current was damaged, the fallback never ran, and the next start marked it failed (Codex P2).launch()now execs that trial with one attempt. If the exec fails, it records the failure withFailTrialand returns the error.Rollout
The fallback runs in
ftw-launcher.ftw updatereplaces onlyreleases/<tag>, not/opt/ftw/ftw-launcher(ADR 0007 decision 14; docs/native-beta.md "Launcher and command updates"). A box gets this only after an installer refresh from a release that contains it. The changeset says so, and the release notes should ask for the refresh.Tests
slots_damaged_current_test.go: the audit reproTestSelectFallsBackWhenCurrentReleaseIsDamaged(fails on master, passes here), one-time fallback, no fallback without a current receipt, no fallback across schemas, andTestSelectFallbackKeepsTheCrashedTrialMarked.cmd/ftw-launcher/main_test.go:TestTrialExecFailureWithDamagedCurrentRunsPreviousandTestFallbackExecFailureIsRecordedAndNotRetried. These three new tests fail without the second commit.cd go && go test -race -count=1 ./internal/nativeupdate/... ./cmd/ftw-launcher/... ./internal/selfupdate/... ./internal/ftwcli/...: okgo test ./cmd/ftw -run 'Native|Trial|Fallback',go vet ./...andgo build ./...: okRisk
Low. The new path runs only when Select would otherwise return an error, so a healthy box behaves as before. It never crosses a state schema. After a successful fallback,
Prunerefuses to run while the damaged release is stillPrevious, and logs a warning. The next update clears this.🤖 Generated with Claude Code