Auto-merge for PR 433 via VersionBot

Properly handle errors when requesting deltas
This commit is contained in:
resin-io-versionbot[bot] 2017-05-11 19:40:15 +00:00 committed by GitHub
commit f04ace4ae1
3 changed files with 28 additions and 26 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! automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## v4.2.3 - 2017-05-11
* Properly handle errors when requesting deltas [Pablo Carranza Velez]
* Add aufs-tools to the dind supervisor for use when running on aufs [Pagan Gazzard]
## v4.2.2 - 2017-04-27 ## v4.2.2 - 2017-04-27
* Only delete the provisioning key if the supervisor is running on an OS that supports using the deviceApiKey [Pablo Carranza Velez] * Only delete the provisioning key if the supervisor is running on an OS that supports using the deviceApiKey [Pablo Carranza Velez]

View File

@ -1,7 +1,7 @@
{ {
"name": "resin-supervisor", "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.", "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": "4.2.2", "version": "4.2.3",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -69,21 +69,18 @@ do ->
return 'resin/scratch' return 'resin/scratch'
findSimilarImage(imgDest) findSimilarImage(imgDest)
.then (imgSrc) -> .then (imgSrc) ->
new Promise (resolve, reject) ->
Promise.join docker.getRegistryAndName(imgDest), docker.getRegistryAndName(imgSrc), (dstInfo, srcInfo) -> Promise.join docker.getRegistryAndName(imgDest), docker.getRegistryAndName(imgSrc), (dstInfo, srcInfo) ->
tokenEndpoint = "#{config.apiEndpoint}/auth/v1/token" tokenEndpoint = "#{config.apiEndpoint}/auth/v1/token"
authOpts = opts =
auth: auth:
user: 'd_' + uuid user: 'd_' + uuid
pass: apiKey pass: apiKey
sendImmediately: true sendImmediately: true
json: true
timeout: requestTimeout
url = "#{tokenEndpoint}?service=#{dstInfo.registry}&scope=repository:#{dstInfo.imageName}:pull&scope=repository:#{srcInfo.imageName}:pull" url = "#{tokenEndpoint}?service=#{dstInfo.registry}&scope=repository:#{dstInfo.imageName}:pull&scope=repository:#{srcInfo.imageName}:pull"
request.getAsync(url, authOpts) request.getAsync(url, opts)
.spread (res, body) -> .get(1)
try
return JSON.parse(body)
catch e
return {}
.then (b) -> .then (b) ->
opts = opts =
timeout: requestTimeout timeout: requestTimeout
@ -94,7 +91,7 @@ do ->
bearer: b?.token bearer: b?.token
sendImmediately: true sendImmediately: true
opts = _.merge(opts, deltaAuthOpts) opts = _.merge(opts, deltaAuthOpts)
new Promise (resolve, reject) ->
progress request.get("#{config.deltaHost}/api/v2/delta?src=#{imgSrc}&dest=#{imgDest}", opts) progress request.get("#{config.deltaHost}/api/v2/delta?src=#{imgSrc}&dest=#{imgDest}", opts)
.on 'progress', (progress) -> .on 'progress', (progress) ->
# In request-progress ^2.0.1, "percentage" is a ratio from 0 to 1 # In request-progress ^2.0.1, "percentage" is a ratio from 0 to 1