build: print the image ID with --quiet when using the containerd worker - #5170
Open
locker95 wants to merge 1 commit into
Open
build: print the image ID with --quiet when using the containerd worker#5170locker95 wants to merge 1 commit into
locker95 wants to merge 1 commit into
Conversation
When buildkitd runs with the containerd worker, the built image does not need loading into the image store, and `nerdctl build -q` printed nothing: the digest was only printed by the load path taken with the OCI worker. Request a buildkit metadata file in quiet mode too, and print the digest from it after a successful build, so that `build -q` consistently outputs the image identifier. Fixes containerd#2015 Signed-off-by: Dean Chen <862469039@qq.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.
Fixes #2015.
As confirmed by @suyanhanx, and per the root cause identified by @austinvazquez ("Image digest is printed during quiet mode only if image is loaded"): with the containerd worker,
needsLoadingis false andbuild -qprinted nothing, sonerdctl run $(nerdctl build -q .)could not work. This change also requests a buildkit--metadata-filein quiet mode when the image is not loaded, and printscontainerimage.digestto stdout after a successful build — the same format the load path prints.The metadata temp file is consumed (and removed) whenever created; a missing digest stays fatal for
--iidfilebut is only a debug log in quiet mode, since some outputs (e.g.--output type=local) legitimately carry no image digest.Testing: a unit test covers digest extraction and temp-file removal (verified locally on macOS); a new
TestBuildQuietintegration test asserts the stdout ofbuild -qis a valid digest and that the printed ID is runnable. Locally I could only compile-verify the Linux/buildkitd path (GOOS=linux go build ./.../go vet/go test -c), so I am relying on CI for end-to-end verification.This patch was developed with the assistance of an AI tool (Claude); I have reviewed and tested the change and take responsibility for it.