Send the error as a task argument

Note that if apptask dies, we will automatically restart the repair
task with the args.
This commit is contained in:
Girish Ramakrishnan
2019-09-22 22:50:33 -07:00
parent 0cd4f133aa
commit a89482d4fa
2 changed files with 10 additions and 8 deletions

View File

@@ -634,6 +634,7 @@ 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) {
@@ -1351,7 +1352,7 @@ function repair(appId, data, auditSource, callback) {
const restoreConfig = data.backupId ? { backupId: data.backupId, backupFormat: data.backupFormat, oldManifest: app.manifest } : null; // when null, apptask simply reinstalls
const overwriteDns = 'overwriteDns' in data ? data.overwriteDns : false;
scheduleTask(appId, { restoreConfig, overwriteDns }, values, function (error, result) {
scheduleTask(appId, { restoreConfig, overwriteDns, error: app.error }, values, function (error, result) {
if (error) return callback(error);
eventlog.add(eventlog.ACTION_APP_REPAIR, auditSource, { taskId: result.taskId, app });