Fixes in app restart behavior:

* Compare config vars to trigger an app restart
* In delete-then-download, only delete when a download is needed
This commit is contained in:
Pablo Carranza Velez 2016-10-03 18:51:44 -03:00
parent 8b2e86bcae
commit 4785437ba8
2 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,5 @@
* In delete-then-download, only delete when a download is needed [Pablo]
* Compare config vars to trigger an app restart [Pablo]
* Fix disabling logs to display on newer OS with different service name [Pablo]
* In cleanup, normalize all image tags for comparison [Pablo]
* Use getRegistryAndName from docker-toolbelt 1.2.0 [Pablo]

View File

@ -474,9 +474,13 @@ updateStrategies =
logSystemEvent(logTypes.updateApp, app) if localApp.imageId == app.imageId
utils.getKnexApp(localApp.appId)
.tap(kill)
.then(deleteImage)
.then ->
fetch(app) if needsDownload
.then (appFromDB) ->
# If we don't need to download a new image,
# there's no use in deleting the image
if needsDownload
deleteImage(appFromDB)
.then ->
fetch(app)
.then ->
start(app)
.catch (err) ->
@ -540,6 +544,9 @@ formatLocalApps = (apps) ->
app = _.pick(app, [ 'appId', 'commit', 'imageId', 'env', 'config', 'name' ])
return localApps
restartVars = (conf) ->
return _.pick(conf, [ 'RESIN_DEVICE_RESTART', 'RESIN_RESTART' ])
compareForUpdate = (localApps, remoteApps) ->
remoteAppIds = _.keys(remoteApps)
localAppIds = _.keys(localApps)
@ -551,7 +558,8 @@ compareForUpdate = (localApps, remoteApps) ->
toBeUpdated = _.filter toBeUpdated, (appId) ->
localApp = _.omit(localApps[appId], 'config')
remoteApp = _.omit(remoteApps[appId], 'config')
return !_.isEqual(remoteApp, localApp)
return !_.isEqual(remoteApp, localApp) or
!_.isEqual(restartVars(JSON.parse(localApps[appId].config)), restartVars(JSON.parse(remoteApps[appId].config)))
toBeDownloaded = _.filter toBeUpdated, (appId) ->
return !_.isEqual(remoteApps[appId].imageId, localApps[appId].imageId)