Browse Source

Fix parallel push of the same image to different registries

Layer uploads are deduplicated by a "key" made up of the layer DiffID
and the repository name. The repository name being used to form this key
was a remote version of the name that didn't include the name of the
registry. Consequently, pushes of the same layer in a repository with
the same remote name to different registries would wrongly be
deduplicated.

Correct the key by using the full name of the repository, which includes
the registry hostname as well as the image's name.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Aaron Lehmann 9 years ago
parent
commit
1333ef3ca3
1 changed files with 3 additions and 1 deletions
  1. 3 1
      distribution/push_v2.go

+ 3 - 1
distribution/push_v2.go

@@ -137,6 +137,7 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, ima
 	descriptorTemplate := v2PushDescriptor{
 	descriptorTemplate := v2PushDescriptor{
 		v2MetadataService: p.v2MetadataService,
 		v2MetadataService: p.v2MetadataService,
 		repoInfo:          p.repoInfo,
 		repoInfo:          p.repoInfo,
+		ref:               p.ref,
 		repo:              p.repo,
 		repo:              p.repo,
 		pushState:         &p.pushState,
 		pushState:         &p.pushState,
 	}
 	}
@@ -222,13 +223,14 @@ type v2PushDescriptor struct {
 	layer             layer.Layer
 	layer             layer.Layer
 	v2MetadataService *metadata.V2MetadataService
 	v2MetadataService *metadata.V2MetadataService
 	repoInfo          reference.Named
 	repoInfo          reference.Named
+	ref               reference.Named
 	repo              distribution.Repository
 	repo              distribution.Repository
 	pushState         *pushState
 	pushState         *pushState
 	remoteDescriptor  distribution.Descriptor
 	remoteDescriptor  distribution.Descriptor
 }
 }
 
 
 func (pd *v2PushDescriptor) Key() string {
 func (pd *v2PushDescriptor) Key() string {
-	return "v2push:" + pd.repo.Named().Name() + " " + pd.layer.DiffID().String()
+	return "v2push:" + pd.ref.FullName() + " " + pd.layer.DiffID().String()
 }
 }
 
 
 func (pd *v2PushDescriptor) ID() string {
 func (pd *v2PushDescriptor) ID() string {