daemon/containerd: fix label!= filter ignoring images without label#52338
Merged
vvoland merged 1 commit intomoby:masterfrom Apr 16, 2026
Merged
daemon/containerd: fix label!= filter ignoring images without label#52338vvoland merged 1 commit intomoby:masterfrom
vvoland merged 1 commit intomoby:masterfrom
Conversation
vvoland
reviewed
Apr 10, 2026
Contributor
vvoland
left a comment
There was a problem hiding this comment.
Thanks! A couple of suggestions
fc9a5d7 to
5ceaf41
Compare
vvoland
reviewed
Apr 10, 2026
5ceaf41 to
c82009a
Compare
vvoland
reviewed
Apr 13, 2026
Contributor
vvoland
left a comment
There was a problem hiding this comment.
Failure related:
=== FAIL: amd64.integration-cli TestDockerDaemonSuite/TestPruneImageLabel (21.40s)
docker_cli_prune_unix_test.go:312: assertion failed: strings.Contains(strings.TrimSpace(out), id2) is true
--- FAIL: TestDockerDaemonSuite/TestPruneImageLabel (21.40s)
949c8dd to
5a46906
Compare
Prior to this fix, setupLabelFilter treated a missing label as a non-match regardless of whether the filter was negated. This caused 'docker image prune --filter label!=key=value' to silently skip images that don't have the label at all, even though those images clearly do not have label=value and should be pruned. The fix: when a label is absent and the check is negated (label!=), we continue instead of returning nil, allowing the image to match. For non-negated checks (label=), the existing early-return is kept. A regression test is added in prune_test.go covering: - label!=key=value matches images without the label - label=key=value does NOT match images without the label Signed-off-by: Sahil Singh <sahiilsiingh37@gmail.com>
5a46906 to
d994daf
Compare
|
@vvoland @thaJeztah, on the surface, this appears to address one of my earlier reports in #50618; I'll verify when I get chance if you guys don't confirm and/or close first. |
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.
docker image pruneignores label!= filter on Docker 29+ #52334What changed
setupLabelFilter(daemon/containerd/image_list.go) where negated filter checks (label!=key=value) incorrectly failed when the image was missing the label entirely.TestSetupLabelFilterNegativeValue) into a newprune_test.gofile.Why
Prior to this fix, the containerd
setupLabelFilterlogic treated a missing label as a non-match regardless of whether the filter was negated. This caused commands likedocker image prune --filter label!=key=valueto silently skip images that don't have the label at all. Sincecontainerd-snapshotteris enabled by default in Docker 29+, this caused a regression in pruning behavior where images lacking a key inexplicably failed to be deleted.Validation
docker image prune -a --force --filter 'label!=on_prune=keep'correctly reclaims space and deletes the image on the containerd backend.image_labelfilter_test.gopass successfully:label!=key=valuecorrectly matches images missing the label.label=key=valuecorrectly does not match images missing the label.label!=key=othercorrectly matches images with the key but a different value.