Skip to content

fix(updater): a restart keeps the release that is running - #1073

Closed
frahlg wants to merge 1 commit into
masterfrom
989-restart-keeps-running-image
Closed

frahlg wants to merge 1 commit into
masterfrom
989-restart-keeps-running-image

Conversation

@frahlg

@frahlg frahlg commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

What happened

On 2026-09-05 at 22:09 local, a beta box on v2.14.0-beta.1 answered one press of Restart by pulling ghcr.io/srcfl/ftw:v2.0.0-beta.2 and recreating Core on it. The old image knew nothing of the loadpoint the operator had added since, so the car did not charge and the operator removed the charger to charge by hand.

Chain of events, from the box:

  1. POST /api/config at 22:09:26 (the operator removed the loadpoint in Settings), then the "Restart required" dialog and Restart now at 22:09:29.
  2. Core called Trigger("restart", "") — no target.
  3. The updater ran compose pull and compose up -d --force-recreate with no FTW_IMAGE_TAG in the environment, so compose read .env.
  4. .env said FTW_IMAGE_TAG=v2.0.0-beta.2, written on 17 August. Every update since ran with the tag in the process environment only; the .env pin is written by the updater's self-replacement step, and the updater that ran those updates predated it.

Without a .env pin the result is the registry's :latest, which today is v2.3.2. Either way a restart on a beta box is a downgrade. Issue #989 saw the same mechanism after a rollback.

The fix

  • Updater: a restart with no target reads the running container's image reference and pins its tag for the pull and the recreate. A running image on a moving tag (a dev build on :latest) keeps today's behaviour. A restart that names a target must name an immutable tag, as update already must.
  • Core: TriggerRestart names the running release (Version, when it is a stable or beta tag). An updater from before this change accepts a target on restart and pins it, so a new Core keeps its release on an old sidecar too. A dev build sends no target.

Verification

  • go test ./cmd/ftw-updater/ ./internal/selfupdate/ — new tests: restart pins the running release in every compose call and in state.json; a named target pins that; a moving target is refused with 400; a running :latest leaves the env unset. TriggerRestart is tested over a real Unix socket for beta, stable, dev and legacy edge versions.
  • go build ./..., go vet on the touched packages, go test ./internal/api/ -run 'Restart|Version|SelfUpdate|Update'.

Not in this PR

Refs #989.

🤖 Generated with Claude Code


Note

Medium Risk
Changes production restart and self-update compose paths that choose the Core image tag; mistakes could still recreate on the wrong release or block valid restarts, but behavior is heavily tested and narrows a known downgrade/data-loss scenario.

Overview
Restart no longer swaps FTW to a different image when compose re-resolves ${FTW_IMAGE_TAG:-latest} from stale .env or registry latest (issue #989).

The updater sidecar now, on restart with no target, inspects the running service image via runningReleaseTag and sets FTW_IMAGE_TAG for pull/recreate; optional caller-supplied targets must pass the same immutable-tag rules as update. Dev builds on :latest still leave env unset.

Core routes operator and in-process restarts through new TriggerRestart, which sends CurrentVersion when it is a stable or beta release tag so older sidecars that only honor an explicit target stay pinned too.

Tests cover pin-from-inspect, pin-from-target, rejection of moving tags, and dev/moving-tag behavior on both updater and selfupdate paths.

Reviewed by Cursor Bugbot for commit 41dc8c5. Bugbot is set up for automated code reviews on this repo. Configure here.

Compose resolves `${FTW_IMAGE_TAG:-latest}` afresh on every recreate. The
restart path sent no tag, so the recreate took whatever .env pinned or the
registry's :latest named. On 2026-09-05 22:09 a beta box on v2.14.0-beta.1
answered one press of Restart by pulling v2.0.0-beta.2: .env still held the
tag of an update from 17 August, because the pin is only written by the
updater's self-replacement step and the updater that ran the later updates
predated it. The old image knew nothing of the loadpoint, so the car did not
charge and the operator removed the charger to charge by hand.

The updater now reads the running container's tag and pins it for the
recreate. Core names its own release when it asks for a restart, which keeps
the release on an older updater as well. A build without a release tag still
lets compose resolve the image, which is the dev path.

Refs #989.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-06T05:51:52.477044Z 41dc8c5 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41dc8c57ab

ℹ️ 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".

Comment on lines +733 to +734
if isImmutableReleaseTag(c.cfg.CurrentVersion) {
target = c.cfg.CurrentVersion

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the test-only reported version out of restart targets

When FTW_SELFUPDATE_CURRENT_VERSION is set, cfg.CurrentVersion is deliberately a fabricated checker value used by dev/QA to simulate update availability, rather than the version actually running (see go/cmd/ftw/main.go lines 2392-2405). Using it as the restart target makes the updater pull and recreate Core on that simulated version, so pressing Restart can unexpectedly switch or downgrade a QA installation instead of preserving its running image. The restart target needs to come from the real build version or be left empty for sidecar inspection.

Useful? React with 👍 / 👎.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 41dc8c5. Configure here.

if isImmutableReleaseTag(c.cfg.CurrentVersion) {
target = c.cfg.CurrentVersion
}
return c.Trigger(ctx, "restart", target)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restart pin uses version identity

Medium Severity

TriggerRestart pins CurrentVersion whenever it looks like a release tag, so the sidecar skips reading the running image. That value is the product identity (baked Version, or FTW_SELFUPDATE_CURRENT_VERSION), which can differ from the container tag when FTW_IMAGE_TAG is empty or not adopted. A beta restart can then recreate on the baked stable release.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 41dc8c5. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approved: Cursor Bugbot was present and finished as skipped, so the required automated-review signal did not complete successfully. No reviewers assigned (no CODEOWNERS match on the changed paths).

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant