Browse code

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 authored on 2016/06/18 14:27:03
Showing 1 changed files
... ...
@@ -137,6 +137,7 @@ func (p *v2Pusher) pushV2Tag(ctx context.Context, ref reference.NamedTagged, ima
137 137
 	descriptorTemplate := v2PushDescriptor{
138 138
 		v2MetadataService: p.v2MetadataService,
139 139
 		repoInfo:          p.repoInfo,
140
+		ref:               p.ref,
140 141
 		repo:              p.repo,
141 142
 		pushState:         &p.pushState,
142 143
 	}
... ...
@@ -222,13 +223,14 @@ type v2PushDescriptor struct {
222 222
 	layer             layer.Layer
223 223
 	v2MetadataService *metadata.V2MetadataService
224 224
 	repoInfo          reference.Named
225
+	ref               reference.Named
225 226
 	repo              distribution.Repository
226 227
 	pushState         *pushState
227 228
 	remoteDescriptor  distribution.Descriptor
228 229
 }
229 230
 
230 231
 func (pd *v2PushDescriptor) Key() string {
231
-	return "v2push:" + pd.repo.Named().Name() + " " + pd.layer.DiffID().String()
232
+	return "v2push:" + pd.ref.FullName() + " " + pd.layer.DiffID().String()
232 233
 }
233 234
 
234 235
 func (pd *v2PushDescriptor) ID() string {