Skip to content

Commit bb35c30

Browse files
committed
Verify images in manifest list are not dangling and pruned
Vendor in latest containers/common Currently if you create an un tagged image and add it to a manifest list, podman image prune will remove the image, and leave you with a broken manifest list. This PR removes the image from dangling in this situation and prevents the pruning. We have seen this trigger issues with RamaLama which is creating manifest lists in this manner, and then users pruning the images. Verifing: containers/common#2360 Signed-off-by: Daniel J Walsh <[email protected]>
1 parent a444a2a commit bb35c30

File tree

22 files changed

+176
-194
lines changed

22 files changed

+176
-194
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ $(IN_CONTAINER): %-in-container:
363363
$(PODMANCMD) run --rm --env HOME=/root \
364364
-v $(CURDIR):/src -w /src \
365365
--security-opt label=disable \
366-
docker.io/library/golang:1.22 \
366+
docker.io/library/golang:1.23 \
367367
make $(*)
368368

369369

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,5 @@ require (
235235
gopkg.in/yaml.v2 v2.4.0 // indirect
236236
tags.cncf.io/container-device-interface/specs-go v1.0.0 // indirect
237237
)
238+
239+
replace github.com/containers/common => github.com/rhatdan/common v0.47.1-0.20250318135319-2242b2e1f465

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ github.com/containernetworking/plugins v1.6.2 h1:pqP8Mq923TLyef5g97XfJ/xpDeVek4y
7878
github.com/containernetworking/plugins v1.6.2/go.mod h1:SP5UG3jDO9LtmfbBJdP+nl3A1atOtbj2MBOYsnaxy64=
7979
github.com/containers/buildah v1.39.1-0.20250321123219-bc4d7eb70fe3 h1:F5qpz8HsQ/nxhArveDEgskbyOjFuSsEahevt4JHAePQ=
8080
github.com/containers/buildah v1.39.1-0.20250321123219-bc4d7eb70fe3/go.mod h1:kCk5Le5CiMazPfGhF8yg43LQa1YLKqBZNnI4PTq+W/U=
81-
github.com/containers/common v0.62.3-0.20250321171839-dbeb17e40c80 h1:U605lFaEyA0zsy4+gqZxth9V2Dl1UXBfcamA3cnQ33E=
82-
github.com/containers/common v0.62.3-0.20250321171839-dbeb17e40c80/go.mod h1:IW8fUkTIwJkeclyROeASOV5FvFBpHjtQj/XBXffhuBk=
8381
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
8482
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
8583
github.com/containers/gvisor-tap-vsock v0.8.4 h1:z7MqcldnXYGaU6uTaKVl7RFxTmbhNsd2UL0CyM3fdBs=
@@ -438,6 +436,8 @@ github.com/prometheus/common v0.57.0 h1:Ro/rKjwdq9mZn1K5QPctzh+MA4Lp0BuYk5ZZEVho
438436
github.com/prometheus/common v0.57.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
439437
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
440438
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
439+
github.com/rhatdan/common v0.47.1-0.20250318135319-2242b2e1f465 h1:aV/PjGzklc+iNdy86HriZ/yQ25h5sctFOFIy8O9inIs=
440+
github.com/rhatdan/common v0.47.1-0.20250318135319-2242b2e1f465/go.mod h1:l7TYE/GilpOcGkrErMCRHfvUnftyhjUGrSL/0gYad0M=
441441
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
442442
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
443443
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=

pkg/domain/infra/abi/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ func (ir *ImageEngine) Tree(ctx context.Context, nameOrID string, opts entities.
597597
if err != nil {
598598
return nil, err
599599
}
600-
tree, err := image.Tree(opts.WhatRequires)
600+
tree, err := image.Tree(ctx, opts.WhatRequires)
601601
if err != nil {
602602
return nil, err
603603
}

test/system/012-manifest.bats

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,30 @@ function manifestListAddArtifactOnce() {
324324
manifestListAddArtifactOnce
325325
done
326326
}
327+
328+
@test "manifest list images should not be marked as dangling" {
329+
# build image and attach it to a manifest list
330+
mlist=m-$(safename)
331+
run_podman build -q -f - <<< "from scratch"
332+
iid=${output}
333+
run_podman manifest create ${mlist} ${iid}
334+
335+
# verify image is not dangling, and is not remove via prune
336+
run_podman images --filter dangling=true
337+
assert "$output" != "sha256:${iid}" "Verify the filter dangling does not list the image"
338+
run_podman image prune --force
339+
assert "$output" != "${iid}" "Verify the prune does not remove the non dangling image"
340+
run_podman image exists ${iid}
341+
342+
# Remove manifes
343+
run_podman manifest rm ${mlist}
344+
345+
# verify the image is now dangling, and is removed via prune
346+
run_podman images -q --filter dangling=true --no-trunc
347+
assert "$output" == "sha256:${iid}" "Verify the filter dangling does list the image"
348+
run_podman image prune --force
349+
assert "$output" == "${iid}" "Verify that prune does not remove the dangling image"
350+
run_podman 1 image exists ${iid}
351+
}
352+
327353
# vim: filetype=sh

vendor/github.com/containers/common/libimage/copier.go

Lines changed: 2 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/history.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/image.go

Lines changed: 15 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/image_tree.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/import.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/layer_tree.go

Lines changed: 26 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/load.go

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/common/libimage/manifest_list.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)