fix: remove only the images the deploy replaced, never every unused one #16

Open
christianmanivong wants to merge 1 commits from fix/remove-only-replaced-images into main
pull from: fix/remove-only-replaced-images
Owner

Summary

The deploy ended with docker image prune -af: every image no container uses at that moment, on a host that may run other things too. The KB's copy of the same line took the license server's rollback images on compute-01 on 2026-10-23 (NetOrk/kb-server#157). The line came from here, written when every target was netOrk's alone. On a customer host that also runs other things, it removes their images too.

Changes

  • Before the swap, deploy.sh records the image IDs netOrk's own containers use (compose ps -aq … | xargs docker inspect --format '{{.Image}}').
  • After the verification and the migration it hands those IDs to the new remote/remove_replaced_images.sh. The script removes each image by its tags, or by its ID once a moving tag such as latest-dev left it without one. It keeps any image a container (netOrk's or anyone else's) still uses; a redeploy of the same tag therefore replaces nothing.
  • README step 12 describes the new behaviour.

Testing

  • tests/test_remote_replaced_images.py runs the script against a fake docker and covers five cases:
    • the replaced release goes by every tag;
    • an image in use stays;
    • another project's image is never named;
    • an untagged leftover goes by its ID;
    • nothing to remove is no failure.
  • tests/test_deploy_replaced_images.py: no prune -af; the IDs are recorded before the recreate and removed after the migration, through the script.
  • Full suite: 82 passed. shellcheck is clean.
## Summary The deploy ended with `docker image prune -af`: every image no container uses at that moment, on a host that may run other things too. The KB's copy of the same line took the license server's rollback images on compute-01 on 2026-10-23 (NetOrk/kb-server#157). The line came from here, written when every target was netOrk's alone. On a customer host that also runs other things, it removes their images too. ## Changes - Before the swap, `deploy.sh` records the image IDs netOrk's own containers use (`compose ps -aq … | xargs docker inspect --format '{{.Image}}'`). - After the verification and the migration it hands those IDs to the new `remote/remove_replaced_images.sh`. The script removes each image by its tags, or by its ID once a moving tag such as `latest-dev` left it without one. It keeps any image a container (netOrk's or anyone else's) still uses; a redeploy of the same tag therefore replaces nothing. - README step 12 describes the new behaviour. ## Testing - `tests/test_remote_replaced_images.py` runs the script against a fake `docker` and covers five cases: - the replaced release goes by every tag; - an image in use stays; - another project's image is never named; - an untagged leftover goes by its ID; - nothing to remove is no failure. - `tests/test_deploy_replaced_images.py`: no `prune -af`; the IDs are recorded before the recreate and removed after the migration, through the script. - Full suite: 82 passed. shellcheck is clean.
christianmanivong added 1 commit 2026-10-23 10:08:03 +00:00
The deploy ended with docker image prune -af: every image no container
used at that moment. On a host that runs other things too, that takes
their rollback images; the KB's copy of this line did exactly that on
compute-01 (NetOrk/kb-server#157).

deploy.sh now records the image IDs netOrk's own containers use before
the swap and, after the verification and the migration, hands them to
remote/remove_replaced_images.sh. It removes each by its tags, or by its
ID once a moving tag left it without one, and keeps any image a
container still uses: a redeploy of the same tag replaces nothing.
All checks were successful
CI / check (pull_request) Successful in 19s
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/remove-only-replaced-images:fix/remove-only-replaced-images
git checkout fix/remove-only-replaced-images
Sign in to join this conversation.