mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-23 15:32:24 +00:00
Update resumable-request to v2.0
Turned out that disk I/O can be the bottleneck when applying deltas on some devices. When the disk can’t keep up and consume the downloaded delta, there’s memory bloat due to buffering. The updated version provides far better reliability when the device is under load and pretty much constant memory consumption with any number of concurrent deltas. Change-Type: patch
This commit is contained in:
parent
79277fea68
commit
dc69917b5a
@ -50,7 +50,7 @@
|
||||
"resin-lint": "^1.3.1",
|
||||
"resin-register-device": "^3.0.0",
|
||||
"resin-sync": "^9.3.0",
|
||||
"resumable-request": "^1.0.1",
|
||||
"resumable-request": "^2.0.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"rwlock": "^5.0.0",
|
||||
"semver": "^5.3.0",
|
||||
|
@ -23,9 +23,9 @@ getRepoAndTag = (image) ->
|
||||
registry = ''
|
||||
return { repo: "#{registry}#{imageName}", tag: tagName }
|
||||
|
||||
applyDelta = (imgSrc, deltaUrl, { requestTimeout, applyTimeout, resumeOpts }, onProgress) ->
|
||||
applyDelta = (imgSrc, deltaUrl, applyTimeout, opts, onProgress) ->
|
||||
new Promise (resolve, reject) ->
|
||||
req = resumable(request, { url: deltaUrl, timeout: requestTimeout }, resumeOpts)
|
||||
req = resumable(Object.assign({ url: deltaUrl }, opts))
|
||||
.on('progress', onProgress)
|
||||
.on('retry', onProgress)
|
||||
.on('error', reject)
|
||||
@ -38,7 +38,7 @@ applyDelta = (imgSrc, deltaUrl, { requestTimeout, applyTimeout, resumeOpts }, on
|
||||
deltaStream = dockerDelta.applyDelta(imgSrc, timeout: applyTimeout)
|
||||
res.pipe(deltaStream)
|
||||
.on('id', resolve)
|
||||
.on('error', req.destroy.bind(req))
|
||||
.on('error', req.abort.bind(req))
|
||||
|
||||
do ->
|
||||
_lock = new Lock()
|
||||
@ -103,8 +103,8 @@ do ->
|
||||
deltaSrc = null
|
||||
else
|
||||
deltaSrc = imgSrc
|
||||
resumeOpts = { maxRetries: retryCount, retryInterval }
|
||||
resolve(applyDelta(deltaSrc, deltaUrl, { requestTimeout, applyTimeout, resumeOpts }, onProgress))
|
||||
resumeOpts = { timeout: requestTimeout, maxRetries: retryCount, retryInterval }
|
||||
resolve(applyDelta(deltaSrc, deltaUrl, applyTimeout, resumeOpts, onProgress))
|
||||
.on 'error', reject
|
||||
.then (id) ->
|
||||
getRepoAndTag(imgDest)
|
||||
|
@ -31,6 +31,7 @@ requestOpts =
|
||||
'User-Agent': userAgent
|
||||
|
||||
resumableOpts =
|
||||
timeout: DEFAULT_REQUEST_TIMEOUT
|
||||
maxRetries: DEFAULT_REQUEST_RETRY_COUNT
|
||||
retryInterval: DEFAULT_REQUEST_RETRY_INTERVAL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user