Skip to content

Collect what superseded releases leave on a host - #404

Merged
nicodes merged 2 commits into
mainfrom
release-retention
Nov 25, 2026
Merged

nicodes merged 2 commits into
mainfrom
release-retention

Conversation

@nicodes

@nicodes nicodes commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Why

Komizo never removed what superseded releases left on a host: extracted asset trees, Podman images (referenced only by image ID, all untagged) and exited job containers. A host eventually filled and the capacity gate refused deploys with staging_failed: disk reserve refuses artifact staging.

What

  • src/deployment/retention.rs computes a keep set across every installed instance and application: each instance's current release, a prepared (stopped) release, its previous release (most recent earlier successful deploy with a different release), its newest failed deploy, and any release named by a non-terminal or unresolved operation. Removed-instance tombstones contribute nothing physical; their records stay.
  • Collection removes, in order: asset trees (/var/lib/komizo-assets/<64 lowercase hex> only, renamed to a same-filesystem trash name and then removed; leftover trash is cleaned next run), exited job containers of releases outside the keep set (through a new jobs::remove_finished that reuses the existing ownership proof, cgroup retirement and non-forced rm), and images that no kept release references and no container uses, by exact ID. Only images some stored release document names are candidates. No Podman prune, no volumes, no running containers, never assets/<hex>.json or releases/<hex>.json.
  • komizo-box gc [--dry-run] prints one JSON report (keep set with reasons, items, bytes, errors).
  • The capacity gate in stage() runs collection once when the disk check refuses, then measures again before returning staging_failed.
  • After a deploy reaches ready, collection runs under a 120 second budget.

Locking

stage() now holds a host-wide staging lock (platform--retention) for its whole run. collect requires a Lease on that lock, so the owner command cannot run while anything is staging, and the gate path (which already holds it) and the post-deploy path (which takes it with try_lease) never race stage(). Collection also refuses while another operation is live. The owner command accepts none. Inside the single effect worker only operations merely queued (admitted, their releases already kept) are allowed.

Failure handling

Per-item failures are reported and do not stop collection. Gate and post-deploy runs write journal/<op>/retention-<stage>.json (collected, partial or refused) and never change the deploy's result.

Docs

The README is checked against a reviewed publication source, so the komizo-box gc usage note is not part of this PR and needs that source updated first.

Tests

Unit tests for the keep set (current, previous, redeploys and non-deploy operations, unresolved, shared digests, tombstones, prepared), name validation and trash cleanup, kept releases never removed per class, refusal while live or locked, dry run, and the job container proof. Full suite runs in CI.

Not covered locally: the real Podman JSON field names (Id, Size, ImageID) and podman image rm, which need a host.

🤖 Generated with Claude Code

nicodes and others added 2 commits November 25, 2026 11:11
Compute a keep set across all instances (current, prepared, previous,
newest failed, unresolved operations) and remove asset trees, exited job
containers and images outside it, by exact name or ID and never with a
prune. Expose it as komizo-box gc with a dry run, run it once from the
capacity gate before staging is refused, and run it after a ready deploy.
Collection holds the staging lock and refuses live operations, and its
failure is journalled without failing a deploy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CI requires the README to match its private publication source, so the
gc usage note is withheld from this change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@nicodes
nicodes merged commit 2462115 into main Nov 25, 2026
14 of 16 checks passed
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