Skip to content

Commit f6751f6

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 3e247db commit f6751f6

File tree

11 files changed

+80
-20
lines changed

11 files changed

+80
-20
lines changed

Makefile

+1-1
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

+2
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

+2-2
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.2 h1:YaFMNnuTr7wKYKQDHkm7yyP9HhWVrNB4DA+DjYUS9k4=
8080
github.com/containers/buildah v1.39.2/go.mod h1:Vb4sDbEq06qQqk29mcGw/1qit8dyukpfL4hwNQ5t+z8=
81-
github.com/containers/common v0.62.3-0.20250320113334-33bf9345b5ef h1:OpMI1mIyrKWPGAYlJY9VVjsCXigtk+3ckYE1SN7JxYA=
82-
github.com/containers/common v0.62.3-0.20250320113334-33bf9345b5ef/go.mod h1:vGmB+0zxqbh5Gd0kOKDlC6sIeoMqso3l4ZKg6+G3YFc=
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

+1-1
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

+26
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/history.go

+1-1
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

+15-6
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

+3-2
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

+26-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ github.com/containers/buildah/pkg/sshagent
179179
github.com/containers/buildah/pkg/util
180180
github.com/containers/buildah/pkg/volumes
181181
github.com/containers/buildah/util
182-
# github.com/containers/common v0.62.3-0.20250320113334-33bf9345b5ef
182+
# github.com/containers/common v0.62.3-0.20250320113334-33bf9345b5ef => github.com/rhatdan/common v0.47.1-0.20250318135319-2242b2e1f465
183183
## explicit; go 1.23.0
184184
github.com/containers/common/internal
185185
github.com/containers/common/internal/attributedstring
@@ -1425,3 +1425,4 @@ tags.cncf.io/container-device-interface/pkg/parser
14251425
# tags.cncf.io/container-device-interface/specs-go v1.0.0
14261426
## explicit; go 1.19
14271427
tags.cncf.io/container-device-interface/specs-go
1428+
# github.com/containers/common => github.com/rhatdan/common v0.47.1-0.20250318135319-2242b2e1f465

0 commit comments

Comments
 (0)