Merge pull request #10244 from dmcgowan/registry-panic-fix
Fix write after close on http response
This commit is contained in:
commit
ef33efc9b9
3 changed files with 11 additions and 3 deletions
|
@ -111,6 +111,7 @@ func (o *Output) Close() error {
|
|||
}
|
||||
}
|
||||
o.tasks.Wait()
|
||||
o.dests = nil
|
||||
return firstErr
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,10 @@ func (s *TagStore) pushImage(r *registry.Session, out io.Writer, imgID, ep strin
|
|||
// Send the layer
|
||||
log.Debugf("rendered layer for %s of [%d] size", imgData.ID, layerData.Size)
|
||||
|
||||
checksum, checksumPayload, err := r.PushImageLayerRegistry(imgData.ID, utils.ProgressReader(layerData, int(layerData.Size), out, sf, false, utils.TruncateID(imgData.ID), "Pushing"), ep, token, jsonRaw)
|
||||
prgRd := utils.ProgressReader(layerData, int(layerData.Size), out, sf, false, utils.TruncateID(imgData.ID), "Pushing")
|
||||
defer prgRd.Close()
|
||||
|
||||
checksum, checksumPayload, err := r.PushImageLayerRegistry(imgData.ID, prgRd, ep, token, jsonRaw)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -338,8 +341,12 @@ func (s *TagStore) pushV2Repository(r *registry.Session, eng *engine.Engine, out
|
|||
out.Write(sf.FormatProgress(utils.TruncateID(img.ID), "Image push failed", nil))
|
||||
return err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
err = r.PutV2ImageBlob(endpoint, repoInfo.RemoteName, sumParts[0], manifestSum, utils.ProgressReader(arch, int(img.Size), out, sf, false, utils.TruncateID(img.ID), "Pushing"), auth)
|
||||
prgRd := utils.ProgressReader(arch, int(img.Size), out, sf, false, utils.TruncateID(img.ID), "Pushing")
|
||||
defer prgRd.Close()
|
||||
|
||||
err = r.PutV2ImageBlob(endpoint, repoInfo.RemoteName, sumParts[0], manifestSum, prgRd, auth)
|
||||
if err != nil {
|
||||
out.Write(sf.FormatProgress(utils.TruncateID(img.ID), "Image push failed", nil))
|
||||
return err
|
||||
|
|
|
@ -226,7 +226,7 @@ func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string
|
|||
|
||||
method := "PUT"
|
||||
log.Debugf("[registry] Calling %q %s", method, location)
|
||||
req, err = r.reqFactory.NewRequest(method, location, blobRdr)
|
||||
req, err = r.reqFactory.NewRequest(method, location, ioutil.NopCloser(blobRdr))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue