Skip to content

Keep tagged image pruning best effort - #1897

Open
cookesan wants to merge 1 commit into
basecamp:mainfrom
cookesan:best-effort-tagged-image-prune
Open

Keep tagged image pruning best effort#1897
cookesan wants to merge 1 commit into
basecamp:mainfrom
cookesan:best-effort-tagged-image-prune

Conversation

@cookesan

Copy link
Copy Markdown
Contributor

Summary

  • Keep tagged image pruning best effort when Docker rejects an image removal.
  • Prevent a cleanup conflict from marking an otherwise completed deploy as failed.
  • Update command and CLI expectations for the prune command.

Related Issue

Closes #1799

Tests

  • docker run --rm --platform linux/amd64 -v "$PWD:/workdir" -v kamal_bundle_cache:/usr/local/bundle -w /workdir ruby:3.4 bash -lc './bin/test test/commands/prune_test.rb test/cli/prune_test.rb'
  • docker run --rm --platform linux/amd64 -v "$PWD:/workdir" -v kamal_bundle_cache:/usr/local/bundle -w /workdir ruby:3.4 bash -lc 'bundle exec rubocop lib/kamal/commands/prune.rb test/commands/prune_test.rb test/cli/prune_test.rb'
  • Shell simulation confirming the tagged image prune fragment stays successful when docker rmi exits nonzero.

Copilot AI review requested due to automatic review settings June 28, 2026 01:24

Copilot AI 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.

Pull request overview

This PR makes tagged-image pruning best-effort so deploys don’t get marked as failed when docker rmi refuses to remove an image (e.g., because it’s referenced by retained/stopped containers), aligning behavior with the “cleanup should not fail an otherwise successful deploy” expectation.

Changes:

  • Make tagged image removal tolerant to docker rmi failures by appending || true in the removal loop.
  • Update command-string expectations in command and CLI tests to reflect best-effort pruning behavior.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/kamal/commands/prune.rb Makes tagged-image pruning best-effort by ignoring docker rmi failures within the loop.
test/commands/prune_test.rb Updates expected tagged-image prune command string to include `
test/cli/prune_test.rb Updates CLI output expectations for the images prune command to include `

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Deploy fails on image prune when docker rmi returns non-zero

2 participants