mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-19 11:16:34 +00:00
Auto-merge for PR 433 via VersionBot
Properly handle errors when requesting deltas
This commit is contained in:
commit
f04ace4ae1
@ -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/).
|
||||
|
||||
## 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
|
||||
|
||||
* Only delete the provisioning key if the supervisor is running on an OS that supports using the deviceApiKey [Pablo Carranza Velez]
|
||||
|
@ -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": "4.2.2",
|
||||
"version": "4.2.3",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -69,32 +69,29 @@ do ->
|
||||
return 'resin/scratch'
|
||||
findSimilarImage(imgDest)
|
||||
.then (imgSrc) ->
|
||||
new Promise (resolve, reject) ->
|
||||
Promise.join docker.getRegistryAndName(imgDest), docker.getRegistryAndName(imgSrc), (dstInfo, srcInfo) ->
|
||||
tokenEndpoint = "#{config.apiEndpoint}/auth/v1/token"
|
||||
authOpts =
|
||||
auth:
|
||||
user: 'd_' + uuid
|
||||
pass: apiKey
|
||||
sendImmediately: true
|
||||
url = "#{tokenEndpoint}?service=#{dstInfo.registry}&scope=repository:#{dstInfo.imageName}:pull&scope=repository:#{srcInfo.imageName}:pull"
|
||||
request.getAsync(url, authOpts)
|
||||
.spread (res, body) ->
|
||||
try
|
||||
return JSON.parse(body)
|
||||
catch e
|
||||
return {}
|
||||
.then (b) ->
|
||||
opts =
|
||||
timeout: requestTimeout
|
||||
|
||||
if b?.token?
|
||||
deltaAuthOpts =
|
||||
auth:
|
||||
bearer: b?.token
|
||||
sendImmediately: true
|
||||
opts = _.merge(opts, deltaAuthOpts)
|
||||
Promise.join docker.getRegistryAndName(imgDest), docker.getRegistryAndName(imgSrc), (dstInfo, srcInfo) ->
|
||||
tokenEndpoint = "#{config.apiEndpoint}/auth/v1/token"
|
||||
opts =
|
||||
auth:
|
||||
user: 'd_' + uuid
|
||||
pass: apiKey
|
||||
sendImmediately: true
|
||||
json: true
|
||||
timeout: requestTimeout
|
||||
url = "#{tokenEndpoint}?service=#{dstInfo.registry}&scope=repository:#{dstInfo.imageName}:pull&scope=repository:#{srcInfo.imageName}:pull"
|
||||
request.getAsync(url, opts)
|
||||
.get(1)
|
||||
.then (b) ->
|
||||
opts =
|
||||
timeout: requestTimeout
|
||||
|
||||
if b?.token?
|
||||
deltaAuthOpts =
|
||||
auth:
|
||||
bearer: b?.token
|
||||
sendImmediately: true
|
||||
opts = _.merge(opts, deltaAuthOpts)
|
||||
new Promise (resolve, reject) ->
|
||||
progress request.get("#{config.deltaHost}/api/v2/delta?src=#{imgSrc}&dest=#{imgDest}", opts)
|
||||
.on 'progress', (progress) ->
|
||||
# In request-progress ^2.0.1, "percentage" is a ratio from 0 to 1
|
||||
|
Loading…
Reference in New Issue
Block a user