Skip to content

Commit d1b22d0

Browse files
author
Roy Lin
committed
fix(cri): resolve image reference in RemoveImage (rmi by short tag)
ImageStatus resolves an image reference via resolve_digest (so `crictl inspecti alpine:latest` finds an image stored under its fully-qualified name), but RemoveImage passed the raw reference straight to ImageStore::remove, which only matches an exact key or exact digest — never normalizing a short tag. So `crictl rmi alpine:latest` failed with 'Image not found' for an image stored as docker.io/library/alpine:latest, even though inspecti just resolved it. Resolve the reference to its digest the same way ImageStatus does, then remove by that digest (dropping every reference to the image — the CRI 'remove the image' semantic). Falls back to the raw ref for a bare digest/id or an unknown image, preserving the prior not-found behavior. Found by running the crictl CRI smoke test on current main (16/18 -> rmi was one of the 2 failures). clippy -D warnings clean; 237 cri tests pass.
1 parent 9687e8d commit d1b22d0

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/cri/src/image_service.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,20 @@ impl ImageService for BoxImageService {
322322

323323
tracing::info!(image = %image_spec.image, "CRI RemoveImage");
324324

325+
// Resolve the reference to its digest the same way ImageStatus does, so
326+
// `rmi <short-tag>` matches an image stored under its fully-qualified name
327+
// (ImageStatus resolved it but RemoveImage previously passed the raw ref to
328+
// store.remove, which only exact-matches a key or digest). Removing by the
329+
// resolved digest drops every reference to the image — the CRI
330+
// "remove the image" semantic. Fall back to the raw ref (a bare digest/id,
331+
// or an unknown image) so store.remove still handles it / errors as before.
332+
let target = self
333+
.resolve_digest(&image_spec.image)
334+
.await
335+
.unwrap_or_else(|| image_spec.image.clone());
336+
325337
self.image_store
326-
.remove(&image_spec.image)
338+
.remove(&target)
327339
.await
328340
.map_err(box_error_to_status)?;
329341

0 commit comments

Comments
 (0)