mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-11 12:01:40 +00:00
Implement waitToKill, keep RESIN_OVERRIDE_LOCK, and changelog for update strategies
This commit is contained in:
parent
13dce75a21
commit
1d6811a423
@ -1,3 +1,5 @@
|
|||||||
|
* Refactor the still undocumented special env vars into RESIN_SUPERVISOR_ [Pablo]
|
||||||
|
* Implement several update strategies (kill before download, 0-downtime) [Pablo]
|
||||||
* Fix the error that comes up when no ip addresses are returned by gosuper [Praneeth]
|
* Fix the error that comes up when no ip addresses are returned by gosuper [Praneeth]
|
||||||
* Switched to docker-progress for pull progress. [Page]
|
* Switched to docker-progress for pull progress. [Page]
|
||||||
* Fix semver versioning in tcp-ping endpoint. [Praneeth]
|
* Fix semver versioning in tcp-ping endpoint. [Praneeth]
|
||||||
|
@ -250,6 +250,10 @@ lockPath = (app) ->
|
|||||||
appId = app.appId ? app
|
appId = app.appId ? app
|
||||||
return "/mnt/root/resin-data/#{appId}/resin-updates.lock"
|
return "/mnt/root/resin-data/#{appId}/resin-updates.lock"
|
||||||
|
|
||||||
|
killmePath = (app) ->
|
||||||
|
appId = app.appId ? app
|
||||||
|
return "/mnt/root/resin-data/#{appId}/resin-kill-me"
|
||||||
|
|
||||||
# At boot, all apps should be unlocked *before* start to prevent a deadlock
|
# At boot, all apps should be unlocked *before* start to prevent a deadlock
|
||||||
application.unlockAndStart = unlockAndStart = (app) ->
|
application.unlockAndStart = unlockAndStart = (app) ->
|
||||||
lockFile.unlockAsync(lockPath(app))
|
lockFile.unlockAsync(lockPath(app))
|
||||||
@ -299,6 +303,7 @@ apiPollInterval = (val) ->
|
|||||||
application.poll()
|
application.poll()
|
||||||
|
|
||||||
specialActionEnvVars =
|
specialActionEnvVars =
|
||||||
|
'RESIN_OVERRIDE_LOCK': null # This one is in use, so we keep backwards comp.
|
||||||
'RESIN_SUPERVISOR_UPDATE_STRATEGY': null
|
'RESIN_SUPERVISOR_UPDATE_STRATEGY': null
|
||||||
'RESIN_SUPERVISOR_HANDOVER_TIMEOUT': null
|
'RESIN_SUPERVISOR_HANDOVER_TIMEOUT': null
|
||||||
'RESIN_SUPERVISOR_OVERRIDE_LOCK': null
|
'RESIN_SUPERVISOR_OVERRIDE_LOCK': null
|
||||||
@ -333,9 +338,20 @@ selectAndKill = (appId) ->
|
|||||||
throw new Error('App not found')
|
throw new Error('App not found')
|
||||||
kill(app)
|
kill(app)
|
||||||
|
|
||||||
|
# Wait for app to signal it's ready to die, or timeout to complete (if it is defined and not-empty)
|
||||||
waitToKill = (app, timeout) ->
|
waitToKill = (app, timeout) ->
|
||||||
# TO-DO
|
startTime = Date.now()
|
||||||
# Wait for app to signal it's ready to die, or timeout to complete (if it is defined and not-empty)
|
pollInterval = 100
|
||||||
|
timeout = parseInt(timeout)
|
||||||
|
checkFileOrTimeout = ->
|
||||||
|
fs.statAsync(killmePath(app))
|
||||||
|
.catch (err) ->
|
||||||
|
throw err if isNaN(timeout) or (Date.now() - startTime) < timeout
|
||||||
|
.then ->
|
||||||
|
fs.unlinkAsync(killmePath(app)).catch(_.noop)
|
||||||
|
checkFileOrTimeout()
|
||||||
|
.catch ->
|
||||||
|
Promise.delay(pollInterval).then(checkFileOrTimeout)
|
||||||
|
|
||||||
UPDATE_IDLE = 0
|
UPDATE_IDLE = 0
|
||||||
UPDATE_UPDATING = 1
|
UPDATE_UPDATING = 1
|
||||||
@ -528,7 +544,7 @@ application.update = update = (force) ->
|
|||||||
app = remoteApps[appId]
|
app = remoteApps[appId]
|
||||||
# Restore the complete environment so that it's persisted in the DB
|
# Restore the complete environment so that it's persisted in the DB
|
||||||
app.env = JSON.stringify(remoteAppEnvs[appId])
|
app.env = JSON.stringify(remoteAppEnvs[appId])
|
||||||
forceThisApp = remoteAppEnvs[appId]['RESIN_SUPERVISOR_OVERRIDE_LOCK'] == '1'
|
forceThisApp = remoteAppEnvs[appId]['RESIN_SUPERVISOR_OVERRIDE_LOCK'] == '1' || remoteAppEnvs[appId]['RESIN_OVERRIDE_LOCK'] == '1'
|
||||||
strategy = remoteAppEnvs[appId]['RESIN_SUPERVISOR_UPDATE_STRATEGY']
|
strategy = remoteAppEnvs[appId]['RESIN_SUPERVISOR_UPDATE_STRATEGY']
|
||||||
timeout = remoteAppEnvs[appId]['RESIN_SUPERVISOR_HANDOVER_TIMEOUT']
|
timeout = remoteAppEnvs[appId]['RESIN_SUPERVISOR_HANDOVER_TIMEOUT']
|
||||||
updateUsingStrategy(strategy, apps[appId], app, needsDownload, force || forceThisApp, timeout)
|
updateUsingStrategy(strategy, apps[appId], app, needsDownload, force || forceThisApp, timeout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user