Skip to content

Conversation

tonistiigi
Copy link
Member

When looking up local images from container image store, Get() method only accepts direct name matches. This means that when image name is sent together with a digest value, it is not matched because containerd would expect digest to be part of the image name.

(cherry picked from commit 43580f9)

When looking up local images from container image store, Get()
method only accepts direct name matches. This means that when
image name is sent together with a digest value, it is not matched
because containerd would expect digest to be part of the image name.

Signed-off-by: Tonis Tiigi <[email protected]>
(cherry picked from commit 43580f9)
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the local image resolver to match references including digests by introducing a helper that parses the reference, constructs a name:tag, and verifies the digest when present.

  • Replaced direct calls to is.Get(ctx, ref) with getImageByRef for both resolve modes
  • Added getImageByRef to parse normalized names, handle tags/defaults, and enforce digest matching
  • Imported github.com/containerd/errdefs to signal not-found errors
Comments suppressed due to low confidence (3)

util/resolver/pool.go:249

  • [nitpick] Consider adding unit tests for getImageByRef to verify correct behavior when resolving references with only a digest, with both tag and digest, and when the digest does not match.
func getImageByRef(ctx context.Context, is images.Store, ref string) (images.Image, error) {

util/resolver/pool.go:267

  • The code calls errors.WithStack but there is no import for a package that provides this function. Consider importing "github.com/pkg/errors" or using a standard fmt.Errorf with %w to wrap cerrdefs.ErrNotFound.
return images.Image{}, errors.WithStack(cerrdefs.ErrNotFound)

util/resolver/pool.go:256

  • [nitpick] Replace the hardcoded "latest" with the constant distreference.DefaultTag to avoid a magic string and keep default tag semantics consistent.
tag := "latest"

@tonistiigi tonistiigi merged commit cc8ff80 into moby:v0.23 Jun 16, 2025
140 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants