c8d/inspect: Ignore manifest with missing config
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>
This commit is contained in:
parent
b3e249f401
commit
a64adda4e7
1 changed files with 18 additions and 3 deletions
|
@ -48,11 +48,25 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
|
||||||
err = i.walkImageManifests(ctx, desc, func(img *ImageManifest) error {
|
err = i.walkImageManifests(ctx, desc, func(img *ImageManifest) error {
|
||||||
conf, err := img.Config(ctx)
|
conf, err := img.Config(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
if cerrdefs.IsNotFound(err) {
|
||||||
|
log.G(ctx).WithFields(log.Fields{
|
||||||
|
"manifestDescriptor": img.Target(),
|
||||||
|
}).Debug("manifest was present, but accessing its config failed, ignoring")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errdefs.System(fmt.Errorf("failed to get config descriptor: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
var ociimage ocispec.Image
|
var ociimage ocispec.Image
|
||||||
if err := readConfig(ctx, cs, conf, &ociimage); err != nil {
|
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 errdefs.System(fmt.Errorf("failed to read config of the manifest %v: %w", img.Target().Digest, err))
|
||||||
}
|
}
|
||||||
presentImages = append(presentImages, ociimage)
|
presentImages = append(presentImages, ociimage)
|
||||||
return nil
|
return nil
|
||||||
|
@ -61,7 +75,8 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(presentImages) == 0 {
|
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 {
|
sort.SliceStable(presentImages, func(i, j int) bool {
|
||||||
|
|
Loading…
Reference in a new issue