mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Try to cross-repo mount until success
Don't fallback back immediately to blob upload if the cross-repo mount fails and layer upload is initiated by registry. Instead cancel the upload and re-try cross-repo mount from different source repository before doing full re-upload. Signed-off-by: Michal Minář <miminar@redhat.com>
This commit is contained in:
		
							parent
							
								
									0928f3f2e3
								
							
						
					
					
						commit
						c6dd51c32c
					
				
					 1 changed files with 15 additions and 4 deletions
				
			
		| 
						 | 
					@ -29,7 +29,7 @@ import (
 | 
				
			||||||
	"github.com/docker/docker/registry"
 | 
						"github.com/docker/docker/registry"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const maxRepositoryMountAttempts = 3
 | 
					const maxRepositoryMountAttempts = 4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PushResult contains the tag, manifest digest, and manifest size from the
 | 
					// PushResult contains the tag, manifest digest, and manifest size from the
 | 
				
			||||||
// push. It's used to signal this information to the trust code in the client
 | 
					// push. It's used to signal this information to the trust code in the client
 | 
				
			||||||
| 
						 | 
					@ -379,9 +379,10 @@ func (pd *v2PushDescriptor) Upload(ctx context.Context, progressOutput progress.
 | 
				
			||||||
			pd.v2MetadataService.Remove(mountCandidate)
 | 
								pd.v2MetadataService.Remove(mountCandidate)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		layerUpload = lu
 | 
							if lu != nil {
 | 
				
			||||||
		if layerUpload != nil {
 | 
								// cancel previous upload
 | 
				
			||||||
			break
 | 
								cancelLayerUpload(ctx, mountCandidate.Digest, layerUpload)
 | 
				
			||||||
 | 
								layerUpload = lu
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -583,3 +584,13 @@ func getPathComponents(path string) []string {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return strings.Split(path, "/")
 | 
						return strings.Split(path, "/")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func cancelLayerUpload(ctx context.Context, dgst digest.Digest, layerUpload distribution.BlobWriter) {
 | 
				
			||||||
 | 
						if layerUpload != nil {
 | 
				
			||||||
 | 
							logrus.Debugf("cancelling upload of blob %s", dgst)
 | 
				
			||||||
 | 
							err := layerUpload.Cancel(ctx)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								logrus.Warnf("failed to cancel upload: %v", err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue