1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

pull: use tag service for pulling tagged reference

The tag service does a `HEAD` request to get the manifest digest, where
we can then do a `GET` against the digest.

The `GET` by tag is not cacheable, but the `GET` against the digest is.
This allows proxies to work way better.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2020-10-30 01:52:23 +00:00
parent bb23f1bf61
commit e4cf1c7336

View file

@ -346,10 +346,16 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named, platform
} }
tagOrDigest = digested.Digest().String() tagOrDigest = digested.Digest().String()
} else if tagged, isTagged := ref.(reference.NamedTagged); isTagged { } else if tagged, isTagged := ref.(reference.NamedTagged); isTagged {
manifest, err = manSvc.Get(ctx, "", distribution.WithTag(tagged.Tag())) tagService := p.repo.Tags(ctx)
desc, err := tagService.Get(ctx, tagged.Tag())
if err != nil { if err != nil {
return false, allowV1Fallback(err) return false, allowV1Fallback(err)
} }
manifest, err = manSvc.Get(ctx, desc.Digest)
if err != nil {
return false, err
}
tagOrDigest = tagged.Tag() tagOrDigest = tagged.Tag()
} else { } else {
return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref)) return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref))