Fix crictl images not filtering by repository:tag#2051
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vigneshakaviki The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @vigneshakaviki! |
Some CRI runtimes do not honor the ListImages image name filter, returning all images instead of only those matching the requested repository:tag. Add client-side filtering as a fallback to ensure correct results regardless of runtime behavior. The filter supports exact repo:tag matching, repo-only matching (returns all tags for that repo), and repo@digest matching. Fixes kubernetes-sigs#2008 Signed-off-by: vigneshakaviki <kumarvignesh295@gmail.com>
bd1ff23 to
561ab4b
Compare
Summary
ListImagesas a fallback when the CRI runtime does not honor theListImagesRequestfilterImageFilter.Imagespec, causingcrictl images repo:tagto show unrelated imagesRepoTagsandRepoDigestsFixes #2008
Root Cause
crictl images REPOSITORY:TAGpasses the filter to the CRI runtime viaListImagesRequest.Filter.Image, but some runtimes (e.g. certain containerd configurations) ignore this filter and return all images. There was no client-side fallback filtering.Changes
filterByName()incmd/crictl/image.go— filters image list by matchingRepoTagsorRepoDigestsagainst the user-provided name filtermatchesNameFilter()helper — handles exactrepo:tagmatch, repo-only match (when no tag specified), andrepo@digestmatchListImages(), before sorting and condition filtersTest plan
filterByName: exact repo:tag, repo-only, no match, digest match, tag-specific match