Remove unused codepaths that do deltas from resin/scratch

The supervisor has been doing regular pulls instead of deltas
from scratch for a while now. We remove remaining references to
resin/scratch, and add a handler in docker-utils to fall back
to a regular pull with a null deltaSource (which should never be
called anyways, but is left as a precaution).

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
This commit is contained in:
Pablo Carranza Velez 2018-10-25 17:58:46 -07:00
parent 8298487a88
commit 4bf6f75a4f
3 changed files with 10 additions and 5 deletions

View File

@ -793,7 +793,7 @@ module.exports = class ApplicationManager extends EventEmitter
for availableImage in available
if availableImage.appId == image.appId
return availableImage.name
return 'resin/scratch'
return null
# returns:
# imagesToRemove: images that

View File

@ -59,7 +59,7 @@ module.exports = class Images extends EventEmitter
.catch =>
@reportChange(image.imageId, _.merge(_.clone(image), { status: 'Downloading', downloadProgress: 0 }))
Promise.try =>
if validation.checkTruthy(opts.delta) and opts.deltaSource? and opts.deltaSource != 'resin/scratch'
if validation.checkTruthy(opts.delta) and opts.deltaSource?
@logger.logSystemEvent(logTypes.downloadImageDelta, { image })
@inspectByName(opts.deltaSource)
.then (srcImage) =>

View File

@ -59,14 +59,13 @@ module.exports = class DockerUtils extends DockerToolbelt
{
deltaRequestTimeout, deltaApplyTimeout, deltaRetryCount, deltaRetryInterval,
uuid, currentApiKey, deltaEndpoint, apiEndpoint,
deltaSource, deltaSourceId, deltaVersion, startFromEmpty = false
deltaSource, deltaSourceId, deltaVersion
} = fullDeltaOpts
retryCount = checkInt(deltaRetryCount)
retryInterval = checkInt(deltaRetryInterval)
requestTimeout = checkInt(deltaRequestTimeout)
applyTimeout = checkInt(deltaApplyTimeout)
version = checkInt(deltaVersion)
deltaSource = 'resin/scratch' if startFromEmpty or !deltaSource?
deltaSourceId ?= deltaSource
log = (str) ->
@ -76,6 +75,12 @@ module.exports = class DockerUtils extends DockerToolbelt
log("Unsupported delta version: #{version}. Falling back to regular pull")
return @fetchImageWithProgress(imgDest, fullDeltaOpts, onProgress)
# Since the supervisor never calls this function without a source anymore,
# this should never happen, but we handle it anyways.
if !deltaSource?
log("Falling back to regular pull due to lack of a delta source")
return @fetchImageWithProgress(imgDest, fullDeltaOpts, onProgress)
docker = this
log("Starting delta to #{imgDest}")
@ -110,7 +115,7 @@ module.exports = class DockerUtils extends DockerToolbelt
if not (300 <= res.statusCode < 400 and res.headers['location']?)
throw new Error("Got #{res.statusCode} when requesting image from delta server.")
deltaUrl = res.headers['location']
if deltaSource is 'resin/scratch'
if !deltaSource?
deltaSrc = null
else
deltaSrc = deltaSourceId