fix: report only the retired services a host actually had
CI / check (pull_request) Successful in 17s

`docker rm -f` exits 0 for a container that does not exist, so the
"Removing retired services" step printed "removed container
netork-registry-1" on every deploy of every host, long after the
container was gone. That read as something recreating the registry
each time, and it would hide the one deploy that really removed it.

Check with `docker inspect` first, so only an existing container is
removed and reported. The volume branch needed nothing: `docker volume
rm` already fails for a missing volume.

Closes #7
This commit is contained in:
Christian Manivong committed 2026-10-08 15:22:48 +02:00
1 parent 1d8353046e
commit 1d99e401b9
3 files changed
+51 -2

No files matched your search

+5 -1
View File
@@ -316,6 +316,9 @@ deploy_steps() {
# file, so each would keep running on every host until someone removed it by
# hand. Idempotent: a host that never had one, or was cleaned already, passes
# untouched. Containers first; a volume still in use cannot be removed.
# Only what exists is removed and reported: `docker rm -f` exits 0 for a
# container that is not there, so without the check every deploy said it had
# removed the registry, long after it was gone (NetOrk/deploy#7).
# registry (netork-registry-1, netork_registry_data): the bundled registry:2
# for satellite images. Satellites pull from registry.netork.io; it held one
# old image, nothing had pulled from it in 30 days, and it accepted
@@ -325,7 +328,8 @@ deploy_steps() {
echo "[${SERVER}] Removing retired services..."
run_remote "$SERVER" "removing ${RETIRED_CONTAINERS} ${RETIRED_VOLUMES}" "" \
"for c in ${RETIRED_CONTAINERS}; do \
docker rm -f \$c >/dev/null 2>&1 && echo \"removed container \$c\"; done; \
docker inspect \$c >/dev/null 2>&1 && docker rm -f \$c >/dev/null 2>&1 \
&& echo \"removed container \$c\"; done; \
for v in ${RETIRED_VOLUMES}; do \
docker volume rm \$v >/dev/null 2>&1 && echo \"removed volume \$v\"; done; true" || true