fix: stop printing the image inspect JSON on destroy - #488
Merged
Conversation
`image_exists?` was the only predicate in the driver that shelled out to
docker without silencing it. Its three siblings -- `container_exists?`,
`container_running?`, and `image_in_use?` -- all pass `suppress_output`.
So `kitchen destroy` on an instance with `remove_images` set printed the
image's entire `docker inspect` output -- config, environment, every layer
digest, metadata, descriptor -- some sixty lines of JSON, in the middle of
the destroy output, between the container being removed and the image being
removed:
-----> Destroying <default-ubuntu-2404>...
[Docker] Destroying Docker container 282c247814fc...
[
{
"Id": "sha256:33c8e9c76cc4...",
...
]
[Docker] Removing image with Image ID sha256:33c8e9c76cc4...
Nothing reads it. Only whether the command succeeded is used.
It is still printed under `-l debug`, where the rest of the driver's docker
traffic goes.
The bare ids `docker stop` and `docker rm` echo are left alone: unlike this,
they are what those commands report, not a predicate's incidental output.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
image_exists?is the only predicate in the driver that shells out to docker without silencing it. Its three siblings --container_exists?,container_running?, andimage_in_use?-- all passsuppress_output.So
kitchen destroyon an instance withremove_images: trueprints the image's entiredocker inspectoutput -- config, environment, every layer digest, metadata, descriptor; about sixty lines of JSON -- in the middle of the destroy output, between the container being removed and the image being removed.Nothing reads it. Only whether the command succeeded is used.
Before
After
Still printed under
-l debug, where the rest of the driver's docker traffic goes -- confirmed in the same run.The bare ids
docker stopanddocker rmecho are deliberately left alone: unlike this, they are what those commands report, not a predicate's incidental output.The method also picked up an early return for the no-image case, so the guard reads the same way as
container_exists?andimage_in_use?rather than relying on a modifierrescuespanning an&&.Confirmation
Docker 29.7.2 (Docker Desktop 4.87.0, macOS/arm64), Test Kitchen 4.1.1. Output above is from real
kitchen create/kitchen destroyruns against anubuntu-24.04container withremove_images: true.rake styleclean;rspec318 examples, 0 failures (5 new).