fix(ansible): the swarm prune reads every image from Docker's API, untagged ones included (#6399)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m36s
CI / integration (push) Successful in 1m49s
CI / publish (push) Successful in 1m4s

`docker image ls` on Docker 29 leaves out images with no tag, which is every
image a swarm task pulled by digest: the check run on VDNT-Docker03 saw 4 of
its 58. Missing them only kept them, but superseded digests there would
never have gone. The list now comes from GET /images/json on the socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 11:15:10 -04:00
co-authored by Claude Opus 5.5
parent 6f0903f548
commit b40e672cda
2 changed files with 36 additions and 6 deletions
+2 -2
View File
@@ -72,6 +72,7 @@ def _fake_docker(monkeypatch, prune, answers, removed):
raise answer
return answer
monkeypatch.setattr(prune, "docker", docker)
monkeypatch.setattr(prune, "api", lambda path: answers[path])
def _answers():
@@ -82,8 +83,7 @@ def _answers():
{"Spec": {"TaskTemplate": {"ContainerSpec": {"Image": "proxy:3@sha256:ppp"}}}}]),
"ps -aq": "c1\n",
"container inspect": json.dumps([{"Image": "sha256:9", "Config": {"Image": "local:1"}}]),
"image ls": "sha256:1\nsha256:2\nsha256:3\nsha256:9\n",
"image inspect": json.dumps([
"/images/json": ([
_image("sha256:1", ["registry.example/app:dev"], ["registry.example/app@sha256:aaa"]),
_image("sha256:2", ["proxy:3"], ["proxy@sha256:ppp"]),
_image("sha256:3", ["registry.example/app:old"], ["registry.example/app@sha256:old"], size=500),