Skip to content

Prune app images correctly#134

Merged
mike-sul merged 6 commits into
mainfrom
refact/prune-app-images-correctly
Apr 27, 2026
Merged

Prune app images correctly#134
mike-sul merged 6 commits into
mainfrom
refact/prune-app-images-correctly

Conversation

@mike-sul
Copy link
Copy Markdown
Collaborator

@mike-sul mike-sul commented Apr 23, 2026

Fix and improve image pruning after app uninstallation:

  1. Fix removing or untaging container images referenced/used by apps being uninstalled.
  2. Add an option to remove all unused images after uninstalling apps.

Signed-off-by: Mike Sul <mike.sul@foundries.io>
When multiple versions of the same app exist in the store, uninstall no
longer always preserves the compose directory.

Use CheckAppsStatus to determine accurately whether a specific app
version is installed. It verifies the app bundle index, including the
expected hashes of each bundle file.

If the app being removed is installed, remove its compose directory even
when other versions are present. Preserve the directory only when the
removed version is not installed, since another installed version can
be have its compose project files in this directory.

Signed-off-by: Mike Sul <mike.sul@foundries.io>
Add t.Helper() to App fixture helper methods that wrap composectl
commands such as pull, install, uninstall, run, and stop.

This improves test failure reporting by attributing errors to the caller
test line instead of the helper implementation, making failures easier
to diagnose.

Signed-off-by: Mike Sul <mike.sul@foundries.io>
@mike-sul mike-sul force-pushed the refact/prune-app-images-correctly branch from 87b2e1f to 488b5f6 Compare April 23, 2026 10:17
Replace command-specific uninstall logic with compose.UninstallApps().

Extend checkUserListedApps() with optional multi-version support so an
app name can resolve to all matching versions in the local store.

This allows uninstall to remove every stored version when users specify
only the app name, while exact app URIs still target a specific version.

The change centralizes uninstall checks and cleanup behavior, keeping the
CLI consistent with shared compose package logic.

Signed-off-by: Mike Sul <mike.sul@foundries.io>
@mike-sul mike-sul force-pushed the refact/prune-app-images-correctly branch from 488b5f6 to 931fcdf Compare April 23, 2026 11:12
Add prune type support to UninstallApps() so callers can choose how
image cleanup is performed after uninstall.

Introduce two pruning modes:
- only-app-images: prune only images of apps being uninstalled
- all-unused-images: prune all unused images

composectl uninstall now defaults to pruning images related to the apps
being removed, while --prune enables full unused image cleanup.

This keeps default uninstall behavior more targeted, while still
allowing broader cleanup when explicitly requested.

Note: the only-app-images mode is not fully correct yet. A follow-up
test exposes the issue, and subsequent commits will
address it.

Signed-off-by: Mike Sul <mike.sul@foundries.io>
@mike-sul mike-sul force-pushed the refact/prune-app-images-correctly branch from efccb2b to 3a34398 Compare April 24, 2026 08:20
@mike-sul mike-sul marked this pull request as ready for review April 24, 2026 09:03
@mike-sul mike-sul requested review from detsch April 24, 2026 09:08
@mike-sul
Copy link
Copy Markdown
Collaborator Author

@detsch This PR is ready for a review now.

Fix image pruning in only-app-images mode.

The previous implementation used the Docker image prune API with
dangling=true, which only removes untagged dangling images and did not
prune unused images that were still referenced by tags or digests.

Uninstall now explicitly detects images not used by any container and,
in only-app-images mode, removes only those images related to the apps
being uninstalled.

Add a new all-unused-images mode that removes every image not used by
any container, regardless of whether it is related to compose apps.

This makes uninstall cleanup more accurate for app-specific pruning
while providing an optional broader system cleanup mode.

Signed-off-by: Mike Sul <mike.sul@foundries.io>
@mike-sul mike-sul force-pushed the refact/prune-app-images-correctly branch from 3a34398 to 979c33b Compare April 24, 2026 12:56
@mike-sul mike-sul merged commit 8a6dbf8 into main Apr 27, 2026
4 checks passed
@mike-sul mike-sul deleted the refact/prune-app-images-correctly branch April 27, 2026 07:22
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.

2 participants