diff --git a/src/caas.js b/src/caas.js index d0b9e81ef..38cc98b8b 100644 --- a/src/caas.js +++ b/src/caas.js @@ -5,7 +5,6 @@ exports = module.exports = { setupDone: setupDone, changePlan: changePlan, - upgrade: upgrade, sendHeartbeat: sendHeartbeat, getBoxAndUserDetails: getBoxAndUserDetails, setPtrRecord: setPtrRecord, @@ -56,7 +55,7 @@ CaasError.EXTERNAL_ERROR = 'External Error'; var NOOP_CALLBACK = function (error) { if (error) debug(error); }; function retire(reason, info, callback) { - assert(reason === 'migrate' || reason === 'upgrade'); + assert(reason === 'migrate'); info = info || { }; callback = callback || NOOP_CALLBACK; @@ -172,42 +171,6 @@ function changePlan(options, callback) { }); } -// this function expects a lock -function upgrade(boxUpdateInfo, callback) { - assert(boxUpdateInfo !== null && typeof boxUpdateInfo === 'object'); - - function upgradeError(e) { - tasks.setProgress(tasks.TASK_MIGRATE, { percent: -1, result: e.message }, NOOP_CALLBACK); - callback(e); - } - - tasks.setProgress(tasks.TASK_MIGRATE, { percent: 5, result: 'Backing up for upgrade' }, NOOP_CALLBACK); - - backups.backupBoxAndApps({ userId: null, username: 'upgrader' }, function (error) { - if (error) return upgradeError(error); - - getCaasConfig(function (error, result) { - if (error) return upgradeError(error); - - superagent.post(config.apiServerOrigin() + '/api/v1/boxes/' + result.boxId + '/upgrade') - .query({ token: result.token }) - .send({ version: boxUpdateInfo.version }) - .timeout(30 * 1000) - .end(function (error, result) { - if (error && !error.response) return upgradeError(new Error('Network error making upgrade request: ' + error)); - if (result.statusCode !== 202) return upgradeError(new Error(util.format('Server not ready to upgrade. statusCode: %s body: %j', result.status, result.body))); - - tasks.setProgress(tasks.TASK_MIGRATE, { percent: 10, result: 'Updating base system' }, NOOP_CALLBACK); - - // no need to unlock since this is the last thing we ever do on this box - callback(); - - retire('upgrade'); - }); - }); - }); -} - function sendHeartbeat() { assert(config.provider() === 'caas', 'Heartbeat is only sent for managed cloudrons'); diff --git a/src/cloudron.js b/src/cloudron.js index 42e81a9f4..e3d212e73 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -82,7 +82,6 @@ CloudronError.EXTERNAL_ERROR = 'External Error'; CloudronError.BAD_STATE = 'Bad state'; CloudronError.ALREADY_UPTODATE = 'No Update Available'; CloudronError.NOT_FOUND = 'Not found'; -CloudronError.SELF_UPGRADE_NOT_SUPPORTED = 'Self upgrade not supported'; function initialize(callback) { assert.strictEqual(typeof callback, 'function'); diff --git a/src/routes/cloudron.js b/src/routes/cloudron.js index 0b5af5f3e..5342efc64 100644 --- a/src/routes/cloudron.js +++ b/src/routes/cloudron.js @@ -58,7 +58,6 @@ function update(req, res, next) { updater.updateToLatest(auditSource(req), function (error) { if (error && error.reason === UpdaterError.ALREADY_UPTODATE) return next(new HttpError(422, error.message)); if (error && error.reason === UpdaterError.BAD_STATE) return next(new HttpError(409, error.message)); - if (error && error.reason === UpdaterError.SELF_UPGRADE_NOT_SUPPORTED) return next(new HttpError(412, error.message)); if (error) return next(new HttpError(500, error)); next(new HttpSuccess(202, {})); diff --git a/src/routes/sysadmin.js b/src/routes/sysadmin.js index ec58304b0..89de0700e 100644 --- a/src/routes/sysadmin.js +++ b/src/routes/sysadmin.js @@ -42,7 +42,6 @@ function update(req, res, next) { updater.updateToLatest(auditSource, function (error) { if (error && error.reason === UpdaterError.ALREADY_UPTODATE) return next(new HttpError(422, error.message)); if (error && error.reason === UpdaterError.BAD_STATE) return next(new HttpError(409, error.message)); - if (error && error.reason === UpdaterError.SELF_UPGRADE_NOT_SUPPORTED) return next(new HttpError(412, error.message)); if (error) return next(new HttpError(500, error)); next(new HttpSuccess(202, {})); diff --git a/src/updater.js b/src/updater.js index 9310cdb61..99ca78338 100644 --- a/src/updater.js +++ b/src/updater.js @@ -54,7 +54,6 @@ UpdaterError.EXTERNAL_ERROR = 'External Error'; UpdaterError.BAD_STATE = 'Bad state'; UpdaterError.ALREADY_UPTODATE = 'No Update Available'; UpdaterError.NOT_FOUND = 'Not found'; -UpdaterError.SELF_UPGRADE_NOT_SUPPORTED = 'Self upgrade not supported'; UpdaterError.NOT_SIGNED = 'Not signed'; function downloadUrl(url, file, callback) { @@ -198,24 +197,13 @@ function update(boxUpdateInfo, auditSource, callback) { // ensure tools can 'wait' on progress tasks.setProgress(tasks.TASK_UPDATE, { percent: 0, message: 'Starting' }, NOOP_CALLBACK); - // initiate the update/upgrade but do not wait for it - if (boxUpdateInfo.upgrade) { - debug('Starting upgrade'); - caas.upgrade(boxUpdateInfo, function (error) { - if (error) { - debug('Upgrade failed with error:', error); - locker.unlock(locker.OP_BOX_UPDATE); - } - }); - } else { - debug('Starting update'); - doUpdate(boxUpdateInfo, function (error) { - if (error) { - debug('Update failed with error:', error); - locker.unlock(locker.OP_BOX_UPDATE); - } - }); - } + debug('Starting update'); + doUpdate(boxUpdateInfo, function (error) { + if (error) { + debug('Update failed with error:', error); + locker.unlock(locker.OP_BOX_UPDATE); + } + }); callback(null); } @@ -228,7 +216,5 @@ function updateToLatest(auditSource, callback) { if (!boxUpdateInfo) return callback(new UpdaterError(UpdaterError.ALREADY_UPTODATE, 'No update available')); if (!boxUpdateInfo.sourceTarballUrl) return callback(new UpdaterError(UpdaterError.BAD_STATE, 'No automatic update available')); - if (boxUpdateInfo.upgrade && config.provider() !== 'caas') return callback(new UpdaterError(UpdaterError.SELF_UPGRADE_NOT_SUPPORTED)); - update(boxUpdateInfo, auditSource, callback); }