Browse Source

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>
Brian Goff 4 years ago
parent
commit
e4cf1c7336
1 changed files with 7 additions and 1 deletions
  1. 7 1
      distribution/pull_v2.go

+ 7 - 1
distribution/pull_v2.go

@@ -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))