Skip to content

fix(updater): remove replaced images after a verified Core update - #1307

Merged
frahlg merged 3 commits into
masterfrom
1305-updater-image-prune
Sep 18, 2026
Merged

frahlg merged 3 commits into
masterfrom
1305-updater-image-prune

Conversation

@frahlg

@frahlg frahlg commented Sep 18, 2026

Copy link
Copy Markdown
Member

Closes #1305.

Problem

ftw-updater pulls a new image for every update and never removes the one it replaced. The owner's Raspberry Pi 4 held 221 images, 12.6 GB, 97 % reclaimable, after months on the beta channel. Every beta box accumulates Core (275 MB) and updater (237 MB) images per update, and optimizer images (760 MB) per optimizer version. A tester without SSH cannot reclaim them, and a full disk breaks the next update: the pull fails and the rollback point cannot be written.

Change

After the update state is done and the service is healthy, and before the sidecar replaces itself (that helper recreates the updater container), the updater lists the tags of its own repositories:

ghcr.io/srcfl/ftw, ghcr.io/srcfl/ftw-updater, ghcr.io/srcfl/ftw-optimizer, ghcr.io/frahlg/forty-two-watts, ghcr.io/frahlg/forty-two-watts-updater

and runs docker image rm on every tag whose image

  • no container uses (running or stopped, from docker ps -aq + inspect), and
  • is not previous_image_id or any entry in previous_images (the images this site could roll back to).

Untagged leftovers of those repositories are removed by ID. Other repositories and user-built images are never touched. Docker itself refuses to remove an image a container references, so a stale inventory cannot delete a running image. Any failure is logged and never turns a finished update into a failure. Restarts and rollbacks clean nothing.

Evidence

  • go test ./cmd/ftw-updater/ passes with four new tests: removal set and ordering after compose up; failure of the container inventory leaves the update done and still self-replaces the sidecar; restart removes nothing; docker images output parsing including untagged rows.
  • Docs: docs/self-update.md. Changeset: patch.

Not in scope: cleanup of migration leftovers in the data directory (history.duckdb, history-hot.db, *.converting); that is a Core concern after a verified history conversion.

🤖 Generated with Claude Code

Every update pulled a new image and left the replaced one behind. A
Raspberry Pi that followed the beta channel for months held 12 GB of
unused Core, updater and optimizer images. A tester without SSH cannot
reclaim them, and a full disk breaks the next update itself.

After the update is done and healthy, and before the sidecar replaces
itself, the updater now removes tags in its own repositories whose image
no container uses and which is not an image the site could roll back
to. Other repositories and user-built images are never touched. A
failed cleanup is logged and never fails the finished update.

Closes #1305

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@frahlg
frahlg merged commit 191dd88 into master Sep 18, 2026
16 checks passed
@frahlg
frahlg deleted the 1305-updater-image-prune branch September 18, 2026 04:15
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.

updater: old Core, updater and optimizer images are never removed, so every beta update eats disk

1 participant