Show better UX when a delta download fails because the image is processing

Change-type: patch
Closes: #679
Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
Cameron Diver 2018-06-13 17:30:35 +01:00
parent 31c6db2ccd
commit 3c9e3bba42
No known key found for this signature in database
GPG Key ID: 69264F9C923F55C1
4 changed files with 14 additions and 3 deletions

View File

@ -5,7 +5,7 @@ logTypes = require '../lib/log-types'
constants = require '../lib/constants'
validation = require '../lib/validation'
{ NotFoundError } = require '../lib/errors'
{ DeltaStillProcessingError, NotFoundError } = require '../lib/errors'
# image = {
# name: image registry/repo@digest or registry/repo:tag
@ -78,6 +78,12 @@ module.exports = class Images extends EventEmitter
.then =>
@logger.logSystemEvent(logTypes.downloadImageSuccess, { image })
return true
.catch DeltaStillProcessingError, =>
# If this is a delta image pull, and the delta still hasn't finished generating,
# don't show a failure message, and instead just inform the user that it's remotely
# processing
@logger.logSystemEvent(logTypes.deltaStillProcessingError)
return false
.catch (err) =>
@logger.logSystemEvent(logTypes.downloadImageError, { image, error: err })
return false

View File

@ -6,7 +6,7 @@ dockerDelta = require 'docker-delta'
_ = require 'lodash'
{ request, resumable } = require './request'
{ envArrayToObject } = require './conversions'
{ InvalidNetGatewayError } = require './errors'
{ DeltaStillProcessingError, InvalidNetGatewayError } = require './errors'
{ checkInt } = require './validation'
applyRsyncDelta = (imgSrc, deltaUrl, applyTimeout, opts, onProgress, log) ->
@ -104,7 +104,7 @@ module.exports = class DockerUtils extends DockerToolbelt
request.getAsync("#{deltaEndpoint}/api/v#{version}/delta?src=#{deltaSource}&dest=#{imgDest}", opts)
.spread (res, data) ->
if res.statusCode in [ 502, 504 ]
throw new Error('Delta server is still processing the delta, will retry')
throw new DeltaStillProcessingError()
switch version
when 2
if not (300 <= res.statusCode < 400 and res.headers['location']?)

View File

@ -20,3 +20,5 @@ export function UnitNotLoadedError(err: string[]): boolean {
}
export class InvalidNetGatewayError extends TypedError { }
export class DeltaStillProcessingError extends TypedError { }

View File

@ -57,6 +57,9 @@ module.exports =
imageAlreadyDeleted:
eventName: 'Image already deleted'
humanName: 'Image already deleted'
deltaStillProcessingError:
eventName: 'Delta still processing remotely.'
humanName: 'Delta still processing remotely. Will retry...'
startService:
eventName: 'Service start'