From 2ed3c832ac9f194fbf735f67388e15bb18826ad2 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Fri, 26 Jan 2018 10:56:17 -0800 Subject: [PATCH] Do a regular pull instead of delta from scratch Signed-off-by: Pablo Carranza Velez --- src/compose/images.coffee | 18 +++++------------- src/lib/docker-utils.coffee | 9 +++------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/compose/images.coffee b/src/compose/images.coffee index 52dc78e9..73de1b4e 100644 --- a/src/compose/images.coffee +++ b/src/compose/images.coffee @@ -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) diff --git a/src/lib/docker-utils.coffee b/src/lib/docker-utils.coffee index d11aa6f2..18c20cf0 100644 --- a/src/lib/docker-utils.coffee +++ b/src/lib/docker-utils.coffee @@ -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)