Add a timeout for update as well
this will send a notification if an update gets stuck
This commit is contained in:
@@ -255,7 +255,8 @@ function appUpdated(eventId, app, callback) {
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function boxUpdated(oldVersion, newVersion, callback) {
|
||||
function boxUpdated(eventId, oldVersion, newVersion, callback) {
|
||||
assert.strictEqual(typeof eventId, 'string');
|
||||
assert.strictEqual(typeof oldVersion, 'string');
|
||||
assert.strictEqual(typeof newVersion, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
@@ -264,7 +265,21 @@ function boxUpdated(oldVersion, newVersion, callback) {
|
||||
const changelogMarkdown = changes.map((m) => `* ${m}\n`).join('');
|
||||
|
||||
actionForAllAdmins([], function (admin, done) {
|
||||
add(admin.id, null, `Cloudron updated to v${newVersion}`, `Cloudron was updated from v${oldVersion} to v${newVersion}.\n\nChangelog:\n${changelogMarkdown}\n`, done);
|
||||
add(admin.id, eventId, `Cloudron updated to v${newVersion}`, `Cloudron was updated from v${oldVersion} to v${newVersion}.\n\nChangelog:\n${changelogMarkdown}\n`, done);
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function boxUpdateError(eventId, errorMessage, callback) {
|
||||
assert.strictEqual(typeof eventId, 'string');
|
||||
assert.strictEqual(typeof errorMessage, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
if (custom.spec().alerts.email) mailer.boxUpdateError(custom.spec().alerts.email, errorMessage);
|
||||
if (!custom.spec().alerts.notifyCloudronAdmins) return callback();
|
||||
|
||||
actionForAllAdmins([], function (admin, done) {
|
||||
mailer.boxUpdateError(admin.email, errorMessage);
|
||||
add(admin.id, eventId, 'Cloudron update failed', `Failed to update Cloudron: ${errorMessage}. Update will be retried in 4 hours`, done);
|
||||
}, callback);
|
||||
}
|
||||
|
||||
@@ -385,7 +400,9 @@ function onEvent(id, action, source, data, callback) {
|
||||
return backupFailed(id, data.taskId, data.errorMessage, callback); // only notify for automated backups or timedout
|
||||
|
||||
case eventlog.ACTION_UPDATE_FINISH:
|
||||
return boxUpdated(data.oldVersion, data.newVersion, callback);
|
||||
if (!data.errorMessage) return boxUpdated(id, data.oldVersion, data.newVersion, callback);
|
||||
if (data.timedOut) return boxUpdateError(id, data.errorMessage, callback);
|
||||
return callback();
|
||||
|
||||
default:
|
||||
return callback();
|
||||
|
||||
Reference in New Issue
Block a user