New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid a HEAD request for each layer in a v2 pull #18418
Conversation
4e93ba6
to
d69e335
Compare
Note that the diff is a bit deceptive. This is simply removing: desc, err := blobs.Stat(context.Background(), di.digest)
if err != nil {
logrus.Debugf("Error statting layer: %v", err)
di.err <- err
return
}
di.size = desc.Size and adding, after the di.size, err = layerDownload.Seek(0, os.SEEK_END)
if err != nil {
di.err <- err
return
}
_, err = layerDownload.Seek(0, os.SEEK_SET)
if err != nil {
di.err <- err
return
} The diff captures the change in a more confusing way. |
Nice! |
LGTM |
We were calling Stat for each layer to get the size so we could indicate progress, but distribution/distribution#1226 made it possible to get the length from the GET request that Open initiates. Saving one round-trip per layer should make pull operations slightly faster and more robust. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
d69e335
to
3958980
Compare
It just occurred to me that the first seek failing (presumably because there's no Content-Length header) shouldn't fail the whole download. It can still continue, but the progress output won't show a progress bar. I'm not sure if this will ever happen in practice, but it seems like a good idea to be robust to this situation. Sorry for changing the commit after a LGTM. |
As a side effect, this tweak made the diff a lot easier to read ;) |
LGTM |
1 similar comment
LGTM |
Avoid a HEAD request for each layer in a v2 pull
We were calling Stat for each layer to get the size so we could indicate
progress, but distribution/distribution#1226 made it
possible to get the length from the GET request that Open initiates.
Saving one round-trip per layer should make pull operations slightly
faster and more robust.