Merge pull request #5770 from wzshiming/fix/push-docker-remote-close

remotes/docker/pusher.go: Fix missing Close() on push to docker remote
This commit is contained in:
Phil Estes 2021-07-21 10:06:41 -04:00 committed by GitHub
commit 6389fc79f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,13 +143,16 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
// TODO: Set updated time?
},
})
resp.Body.Close()
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest)
}
} else if resp.StatusCode != http.StatusNotFound {
err := remoteserrors.NewUnexpectedStatusErr(resp)
log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response")
resp.Body.Close()
return nil, err
}
resp.Body.Close()
}
if isManifest {