Remove extra roundtrip for checking schema1.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
a7481289bb
commit
d64fa3b6b8
@ -94,17 +94,19 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
|||||||
if ref != imageRef {
|
if ref != imageRef {
|
||||||
log.G(ctx).Debugf("PullImage using normalized image ref: %q", ref)
|
log.G(ctx).Debugf("PullImage using normalized image ref: %q", ref)
|
||||||
}
|
}
|
||||||
resolver := docker.NewResolver(docker.ResolverOptions{
|
var (
|
||||||
Hosts: c.registryHosts(r.GetAuth()),
|
resolver = docker.NewResolver(docker.ResolverOptions{
|
||||||
})
|
Hosts: c.registryHosts(r.GetAuth()),
|
||||||
_, desc, err := resolver.Resolve(ctx, ref)
|
})
|
||||||
if err != nil {
|
isSchema1 bool
|
||||||
return nil, errors.Wrapf(err, "failed to resolve image %q", ref)
|
imageHandler containerdimages.HandlerFunc = func(_ context.Context,
|
||||||
}
|
desc imagespec.Descriptor) ([]imagespec.Descriptor, error) {
|
||||||
// We have to check schema1 here, because after `Pull`, schema1
|
if desc.MediaType == containerdimages.MediaTypeDockerSchema1Manifest {
|
||||||
// image has already been converted.
|
isSchema1 = true
|
||||||
isSchema1 := desc.MediaType == containerdimages.MediaTypeDockerSchema1Manifest
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
)
|
||||||
image, err := c.client.Pull(ctx, ref,
|
image, err := c.client.Pull(ctx, ref,
|
||||||
containerd.WithSchema1Conversion,
|
containerd.WithSchema1Conversion,
|
||||||
containerd.WithResolver(resolver),
|
containerd.WithResolver(resolver),
|
||||||
@ -112,6 +114,7 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
|||||||
containerd.WithPullUnpack,
|
containerd.WithPullUnpack,
|
||||||
containerd.WithPullLabel(imageLabelKey, imageLabelValue),
|
containerd.WithPullLabel(imageLabelKey, imageLabelValue),
|
||||||
containerd.WithMaxConcurrentDownloads(c.config.MaxConcurrentDownloads),
|
containerd.WithMaxConcurrentDownloads(c.config.MaxConcurrentDownloads),
|
||||||
|
containerd.WithImageHandler(imageHandler),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to pull and unpack image %q", ref)
|
return nil, errors.Wrapf(err, "failed to pull and unpack image %q", ref)
|
||||||
|
Loading…
Reference in New Issue
Block a user