1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #28966 from aaronlehmann/push-panic

distribution: Fix panic on push
This commit is contained in:
Alexander Morozov 2016-11-30 07:26:58 -08:00 committed by GitHub
commit 523ad6ac71
2 changed files with 11 additions and 8 deletions

View file

@ -523,6 +523,7 @@ func (pd *v2PushDescriptor) layerAlreadyExists(
layerDigests = append(layerDigests, meta.Digest)
}
attempts:
for _, dgst := range layerDigests {
meta := digestToMetadata[dgst]
logrus.Debugf("Checking for presence of layer %s (%s) in %s", diffID, dgst, pd.repoInfo.FullName())
@ -541,15 +542,14 @@ func (pd *v2PushDescriptor) layerAlreadyExists(
}
desc.MediaType = schema2.MediaTypeLayer
exists = true
break
break attempts
case distribution.ErrBlobUnknown:
if meta.SourceRepository == pd.repoInfo.FullName() {
// remove the mapping to the target repository
pd.v2MetadataService.Remove(*meta)
}
default:
progress.Update(progressOutput, pd.ID(), "Image push failed")
return desc, false, retryOnError(err)
logrus.WithError(err).Debugf("Failed to check for presence of layer %s (%s) in %s", diffID, dgst, pd.repoInfo.FullName())
}
}

View file

@ -180,7 +180,7 @@ func TestLayerAlreadyExists(t *testing.T) {
maxExistenceChecks: 1,
metadata: []metadata.V2Metadata{{Digest: digest.Digest("apple"), SourceRepository: "docker.io/library/busybox"}},
remoteErrors: map[digest.Digest]error{digest.Digest("apple"): distribution.ErrAccessDenied},
expectedError: distribution.ErrAccessDenied,
expectedError: nil,
expectedRequests: []string{"apple"},
},
{
@ -310,7 +310,7 @@ func TestLayerAlreadyExists(t *testing.T) {
expectedRemovals: []metadata.V2Metadata{taggedMetadata("key3", "apple", "docker.io/library/busybox")},
},
{
name: "stop on first error",
name: "don't stop on first error",
targetRepo: "user/app",
hmacKey: "key",
metadata: []metadata.V2Metadata{
@ -321,9 +321,12 @@ func TestLayerAlreadyExists(t *testing.T) {
maxExistenceChecks: 3,
remoteErrors: map[digest.Digest]error{"orange": distribution.ErrAccessDenied},
remoteBlobs: map[digest.Digest]distribution.Descriptor{digest.Digest("apple"): {}},
expectedError: distribution.ErrAccessDenied,
expectedRequests: []string{"plum", "orange"},
expectedRemovals: []metadata.V2Metadata{taggedMetadata("key", "plum", "docker.io/user/app")},
expectedError: nil,
expectedRequests: []string{"plum", "orange", "banana"},
expectedRemovals: []metadata.V2Metadata{
taggedMetadata("key", "plum", "docker.io/user/app"),
taggedMetadata("key", "banana", "docker.io/user/app"),
},
},
{
name: "remove outdated metadata",