From e4cf1c733677ff77e51101e2de542373b449b471 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Fri, 30 Oct 2020 01:52:23 +0000 Subject: [PATCH] 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 --- distribution/pull_v2.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index 54b66d01a1..1643a36e04 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -346,10 +346,16 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named, platform } tagOrDigest = digested.Digest().String() } 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 { return false, allowV1Fallback(err) } + + manifest, err = manSvc.Get(ctx, desc.Digest) + if err != nil { + return false, err + } tagOrDigest = tagged.Tag() } else { return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref))