Skip to content

Commit

Permalink
c8d/inspect: Ignore manifest with missing config
Browse files Browse the repository at this point in the history
Fix a failure to inspect image if any of its present manifest references
an image config which isn't present locally.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 5767330)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
  • Loading branch information
vvoland committed Aug 16, 2023
1 parent f1cc576 commit be52b00
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions daemon/containerd/image.go
Expand Up @@ -48,11 +48,19 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
err = i.walkImageManifests(ctx, desc, func(img *ImageManifest) error {
conf, err := img.Config(ctx)
if err != nil {
return err
return fmt.Errorf("failed to get config descriptor: %w", err)
}

var ociimage ocispec.Image
if err := readConfig(ctx, cs, conf, &ociimage); err != nil {
return err
if cerrdefs.IsNotFound(err) {
log.G(ctx).WithFields(log.Fields{
"manifestDescriptor": img.Target(),
"configDescriptor": conf,
}).Debug("manifest present, but its config is missing, ignoring")
return nil
}
return fmt.Errorf("failed to read config of the manifest %v: %w", img.Target().Digest, err)
}
presentImages = append(presentImages, ociimage)
return nil
Expand All @@ -61,7 +69,8 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
return nil, err
}
if len(presentImages) == 0 {
return nil, errdefs.NotFound(errors.New("failed to find image manifest"))
ref, _ := reference.ParseAnyReference(refOrID)
return nil, images.ErrImageDoesNotExist{Ref: ref}
}

sort.SliceStable(presentImages, func(i, j int) bool {
Expand Down

0 comments on commit be52b00

Please sign in to comment.