Auto-merge for PR #680 via VersionBot

Change UX for a delta pull which fails becase delta is still processing
This commit is contained in:
resin-io-versionbot[bot] 2018-06-14 09:22:59 +00:00 committed by GitHub
commit 4efc1de789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 10 deletions

View File

@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).
## v7.11.1 - 2018-06-14
* Show better UX when a delta download fails because the image is processing #680 [Cameron Diver]
* Upgrade TypedError and move docker-utils error to error module #680 [Cameron Diver]
## v7.11.0 - 2018-06-13
* Pin a device to a commit when preload has a pinDevice field #669 [Cameron Diver]

View File

@ -1,7 +1,7 @@
{
"name": "resin-supervisor",
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
"version": "7.11.0",
"version": "7.11.1",
"license": "Apache-2.0",
"repository": {
"type": "git",
@ -72,7 +72,7 @@
"shell-quote": "^1.6.1",
"ts-loader": "^3.5.0",
"ts-node": "^6.0.1",
"typed-error": "~0.1.0",
"typed-error": "^2.0.0",
"typescript": "^2.8.3",
"uglifyjs-webpack-plugin": "^1.0.1",
"versionist": "^2.8.0",

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

@ -3,10 +3,10 @@ DockerToolbelt = require 'docker-toolbelt'
{ DockerProgress } = require 'docker-progress'
Promise = require 'bluebird'
dockerDelta = require 'docker-delta'
TypedError = require 'typed-error'
_ = require 'lodash'
{ request, resumable } = require './request'
{ envArrayToObject } = require './conversions'
{ DeltaStillProcessingError, InvalidNetGatewayError } = require './errors'
{ checkInt } = require './validation'
applyRsyncDelta = (imgSrc, deltaUrl, applyTimeout, opts, onProgress, log) ->
@ -36,7 +36,7 @@ applyBalenaDelta = (docker, deltaImg, token, onProgress, log) ->
log('Using registry auth token')
auth = { authconfig: registrytoken: token }
docker.dockerProgress.pull(deltaImg, onProgress, auth)
.then =>
.then ->
docker.getImage(deltaImg).inspect().get('Id')
module.exports = class DockerUtils extends DockerToolbelt
@ -45,8 +45,6 @@ module.exports = class DockerUtils extends DockerToolbelt
@dockerProgress = new DockerProgress(dockerToolbelt: this)
@supervisorTagPromise = @normaliseImageName(constants.supervisorImage)
InvalidNetGatewayError: class InvalidNetGatewayError extends TypedError
getRepoAndTag: (image) =>
@getRegistryAndName(image)
.then ({ registry, imageName, tagName }) ->
@ -106,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']?)
@ -158,8 +156,8 @@ module.exports = class DockerUtils extends DockerToolbelt
getNetworkGateway: (netName) =>
return Promise.resolve('127.0.0.1') if netName == 'host'
@getNetwork(netName).inspect()
.then (netInfo) =>
.then (netInfo) ->
conf = netInfo?.IPAM?.Config?[0]
return conf.Gateway if conf?.Gateway?
return conf.Subnet.replace('.0/16', '.1') if _.endsWith(conf?.Subnet, '.0/16')
throw new @InvalidNetGatewayError("Cannot determine network gateway for #{netName}")
throw new InvalidNetGatewayError("Cannot determine network gateway for #{netName}")

View File

@ -1,4 +1,5 @@
import { endsWith } from 'lodash';
import TypedError = require('typed-error');
import { checkInt } from './validation';
@ -17,3 +18,7 @@ export function EEXIST(err: { code: string, [key: string]: any }): boolean {
export function UnitNotLoadedError(err: string[]): boolean {
return endsWith(err[0], 'not loaded.');
}
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'