scheduler: stash the containerId in the state

the container id will change when the app is re-configured.
in the future, maybe it's better to do this like sftp.rebuild()
This commit is contained in:
Girish Ramakrishnan
2020-09-01 12:44:48 -07:00
parent 5adfa722d4
commit 9ae4ce82a7
2 changed files with 5 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ let apps = require('./apps.js'),
docker = require('./docker.js'),
_ = require('underscore');
// appId -> { schedulerConfig (manifest), cronjobs }
// appId -> { containerId, schedulerConfig (manifest), cronjobs }
var gState = { };
@@ -124,7 +124,9 @@ function sync() {
var schedulerConfig = app.manifest.addons ? app.manifest.addons.scheduler : null;
if (!appState && !schedulerConfig) return iteratorDone(); // nothing to do
if (appState && _.isEqual(appState.schedulerConfig, schedulerConfig) && appState.cronJobs) return iteratorDone(); // nothing changed
if (appState && appState.cronJobs) { // we had created jobs for this app previously
if (_.isEqual(appState.schedulerConfig, schedulerConfig) && appState.containerId === app.containerId) return iteratorDone(); // nothing changed
}
debug(`sync: adding jobs of ${app.id}`);
@@ -139,7 +141,7 @@ function sync() {
createJobs(app, schedulerConfig, function (error, cronJobs) {
if (error) return iteratorDone(error); // if docker is down, the next sync() will recreate everything for this app
gState[app.id] = { schedulerConfig, cronJobs };
gState[app.id] = { containerId: app.containerId, schedulerConfig, cronJobs };
iteratorDone();
});