Repository navigation
fix(compose): report pinned image IDs after retagging - #5251
Conversation
|
|
||
| func TestComposeImagesAfterRetag(t *testing.T) { | ||
| testCase := nerdtest.Setup() | ||
| testCase.Require = require.All(nerdtest.Private, require.Not(nerdtest.Docker)) |
There was a problem hiding this comment.
Please add a comment to explain why require.Not(nerdtest.Docker)
There was a problem hiding this comment.
Added the comment above the requirement. This regression uses nerdctl-specific image convert to retag the image and image inspect --mode native to check its manifest digest, so it cannot run against Docker.
|
Please squash the commits |
|
Squashed the two commits into aa86f31. The code and regression test are unchanged, including the comment explaining why the test excludes Docker. |
|
|
||
| size, err := imgutil.UnpackedImageSize(ctx, sn, image) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| metaImage := image.Metadata() | ||
| repository, tag := imgutil.ParseRepoTag(metaImage.Name) | ||
| imageID := metaImage.Target.Digest.String() | ||
| imageID := composeImageDigest(info.Labels, metaImage.Target.Digest).String() | ||
| if repository == "" { | ||
| repository = "<none>" | ||
| } |
There was a problem hiding this comment.
ImageID uses the pinned digest, but Size comes from
imgutil.UnpackedImageSize where image is resolved by the current tag.
After retagging, the row is internally inconsistent: I get alpine's ID with busybox's size
There was a problem hiding this comment.
Fixed in 5a360b6. Table and JSON now resolve the pinned digest from the local content store and select the manifest using the container's platform label, so the ID and unpacked size come from the same image. The repository/tag still comes from the container's original image reference. The regression now retags Alpine to BusyBox and compares the full table and JSON output: it failed with the old head (5.9 MiB became 4.8 MiB) and passes with the fix. Local image-store/CLI checks also pass when the original image record or container image name is removed; unavailable pinned content or snapshots return an error instead of reporting another image's size.
|
|
||
| // Image tags can change after a container is created. Prefer the digest pinned | ||
| // at creation, falling back to the current image for containers without it. | ||
| func composeImageDigest(containerLabels map[string]string, fallback digest.Digest) digest.Digest { |
There was a problem hiding this comment.
pinnedImageDigest in pkg/cmd/image/list.go already reads
labels.ImageDigest with identical fallback semantics. Please reuse pinnedImageDigest instead of adding composeImageDigest.
There was a problem hiding this comment.
Done in 5a360b6. Exported the existing helper as image.PinnedImageDigest and reused it in both compose output paths. Removed composeImageDigest; missing/empty/invalid labels keep the existing name-based fallback and debug logging. The existing four helper cases and make test pass.
| testCase.Run(t) | ||
| } | ||
|
|
||
| func TestComposeImageDigestFallback(t *testing.T) { |
There was a problem hiding this comment.
It duplicates the existing TestPinnedImageDigest in pkg/cmd/image/list_test.go case for case.
TestComposeImagesAfterRetag already covers the real behavior
There was a problem hiding this comment.
Removed the duplicate TestComposeImageDigestFallback in 5a360b6 and kept the existing TestPinnedImageDigest coverage. TestComposeImagesAfterRetag now uses Alpine and BusyBox with different rootfs sizes and compares the full table and JSON output, while still checking the quiet short ID. The old head fails the table/JSON regression and the updated head passes all three modes in a private containerd namespace.
Resolve the image content recorded at container creation so compose images reports the original target digest and unpacked size together. Use the container's platform when selecting an indexed manifest and preserve name-based resolution when the digest label is missing or invalid. Reuse the existing pinned image digest helper and cover retagging between images with different rootfs sizes in table, JSON, and quiet output. Explain that native image inspection makes this regression nerdctl-only. Fixes containerd#2198. Assisted-by: Codex Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io>
|
The remaining failure in the current I attempted to rerun only the FreeBSD job, but GitHub returned 403 ( |
|
The attempt 3 FreeBSD job repeats the same timeout after printing |
compose imagesresolves containers through mutable image names, so retagging can change their reported ID or combine the original ID with another image's size. Resolve the pinned local content and container platform for table/JSON output, and reuse the shared pinned-digest helper for quiet output. Preserve name-based resolution for missing or invalid digest labels.Fixes #2198.
Validation: the private-namespace Alpine-to-BusyBox compose regression fails on the old head and passes after the fix for table/JSON size consistency and quiet IDs. Local image-store/CLI checks cover removed image names, fallback labels, platform selection, and unavailable content/snapshots.
make test, builds, changed-code Go lint on all four supported OSes, YAML, module, confinement, license, and commit checks pass. Full lint reproduces the existing Go formatting and shellcheck failures on the clean upstream baseline.AI assistance: Codex assisted with the implementation, regression tests, and PR description.