Do not configure/restore errored apps automatically

This commit is contained in:
Girish Ramakrishnan
2019-09-22 22:34:57 -07:00
parent e5ba4ff973
commit 0cd4f133aa
2 changed files with 8 additions and 6 deletions

View File

@@ -634,7 +634,6 @@ function scheduleTask(appId, args, values, callback) {
tasks.add(tasks.TASK_APP, [ appId, args ], function (error, taskId) {
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
values.error = null;
values.taskId = taskId;
appdb.setTask(appId, values, function (error) {
@@ -1758,6 +1757,7 @@ function restoreInstalledApps(callback) {
getAll(function (error, apps) {
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
apps = apps.filter(app => app.installationState !== exports.ISTATE_ERROR); // remove errored apps. let them be 'repaired' by hand
async.map(apps, function (app, iteratorDone) {
backups.getByAppIdPaged(1, 1, app.id, function (error, results) {
@@ -1765,7 +1765,7 @@ function restoreInstalledApps(callback) {
debug(`marking ${app.fqdn} for restore using restore config ${JSON.stringify(restoreConfig)}`);
appdb.update(app.id, { taskId: null }, function (error) { // clear any stale taskId
appdb.update(app.id, { taskId: null, error: null }, function (error) { // clear any stale taskId
if (error) debug(`Error marking ${app.fqdn} for restore: ${JSON.stringify(error)}`);
scheduleTask(app.id, { restoreConfig, overwriteDns: true }, { installationState: exports.ISTATE_PENDING_RESTORE }, () => iteratorDone()); // always succeed
@@ -1780,14 +1780,16 @@ function configureInstalledApps(callback) {
getAll(function (error, apps) {
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
apps = apps.filter(app => app.installationState !== exports.ISTATE_ERROR); // remove errored apps. let them be 'repaired' by hand
async.map(apps, function (app, iteratorDone) {
debug(`marking ${app.fqdn} for reconfigure`);
appdb.update(app.id, { taskId: null }, function (error) { // clear any stale taskId
appdb.update(app.id, { taskId: null, error: null }, function (error) { // clear any stale taskId
if (error) debug(`Error marking ${app.fqdn} for reconfigure: ${JSON.stringify(error)}`);
scheduleTask(app.id, { oldConfig: app }, { installationState: exports.ISTATE_PENDING_CONFIGURE }, () => iteratorDone()); // always succeed
const oldConfig = _.pick(app, 'location', 'domain', 'fqdn', 'alternateDomains', 'portBindings');
scheduleTask(app.id, { oldConfig }, { installationState: exports.ISTATE_PENDING_CONFIGURE }, () => iteratorDone()); // always succeed
});
}, callback);
});