Do a regular pull instead of delta from scratch

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2018-01-26 10:56:17 -08:00
parent 484a688dbd
commit 2ed3c832ac
2 changed files with 8 additions and 19 deletions

View File

@ -54,25 +54,17 @@ module.exports = class Images extends EventEmitter
.catch =>
@reportChange(image.imageId, _.merge(_.clone(image), { status: 'Downloading', downloadProgress: 0 }))
Promise.try =>
if validation.checkTruthy(opts.delta)
if validation.checkTruthy(opts.delta) and opts.deltaSource and opts.deltaSource != 'resin/scratch'
@logger.logSystemEvent(logTypes.downloadImageDelta, { image })
Promise.try =>
if opts.deltaSource and opts.deltaSource != 'resin/scratch'
@inspectByName(opts.deltaSource)
.then (srcImage) ->
opts.deltaSourceId = srcImage.Id
.then =>
@inspectByName(opts.deltaSource)
.then (srcImage) ->
opts.deltaSourceId = srcImage.Id
@docker.rsyncImageWithProgress(imageName, opts, onProgress)
.then (id) =>
id = 'sha256:' + id
.tap (id) =>
if !hasDigest(imageName)
@docker.getRepoAndTag(imageName)
.then ({ repo, tag }) =>
@docker.getImage(id).tag({ repo, tag })
.then ->
return id
else
return id
else
@logger.logSystemEvent(logTypes.downloadImage, { image })
@docker.fetchImageWithProgress(imageName, opts, onProgress)

View File

@ -23,7 +23,7 @@ applyDelta = (imgSrc, deltaUrl, { requestTimeout, applyTimeout, resumeOpts }, on
else
deltaStream = dockerDelta.applyDelta(imgSrc, timeout: applyTimeout)
res.pipe(deltaStream)
.on('id', resolve)
.on('id', (id) -> resolve('sha256:' + id))
.on('error', req.destroy.bind(req))
module.exports = class DockerUtils extends DockerToolbelt
@ -98,11 +98,8 @@ module.exports = class DockerUtils extends DockerToolbelt
resolve(applyDelta(deltaSrc, deltaUrl, { requestTimeout, applyTimeout, resumeOpts }, onProgress))
.on 'error', reject
.catch dockerDelta.OutOfSyncError, (err) =>
throw err if startFromEmpty
console.log('Falling back to delta-from-empty')
newOpts = _.clone(fullDeltaOpts)
newOpts.startFromEmpty = true
@rsyncImageWithProgress(imgDest, newOpts, onProgress)
console.log('Falling back to regular pull')
@fetchImageWithProgress(imgDest, fullDeltaOpts, onProgress)
fetchImageWithProgress: (image, { uuid, currentApiKey }, onProgress) =>
@getRegistryAndName(image)