diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ec95757..df13062f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/src/application.coffee b/src/application.coffee index 112c9d38..42b9709d 100644 --- a/src/application.coffee +++ b/src/application.coffee @@ -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)