Add overwriteDns arg to install & clone

this is useful in e2e
This commit is contained in:
Girish Ramakrishnan
2019-09-16 09:31:34 -07:00
parent adbe46d369
commit 00f949f156
3 changed files with 20 additions and 12 deletions

View File

@@ -684,7 +684,8 @@ function install(data, user, auditSource, callback) {
env = data.env || {},
mailboxName = data.mailboxName || '',
label = data.label || null,
tags = data.tags || [];
tags = data.tags || [],
overwriteDns = 'overwriteDns' in data ? data.overwriteDns : false;
assert(data.appStoreId || data.manifest); // atleast one of them is required
@@ -790,7 +791,7 @@ function install(data, user, auditSource, callback) {
const restoreConfig = backupId ? { backupId: backupId, backupFormat: backupFormat } : null;
scheduleTask(appId, { restoreConfig }, { installationState: exports.ISTATE_PENDING_INSTALL }, function (error, result) {
scheduleTask(appId, { restoreConfig, overwriteDns }, { installationState: exports.ISTATE_PENDING_INSTALL }, function (error, result) {
if (error) return callback(error);
const newApp = _.extend({ fqdn: domains.fqdn(location, domainObject) }, data, { appStoreId, manifest, location, domain, portBindings });
@@ -1329,7 +1330,7 @@ function restore(appId, data, auditSource, callback) {
};
const restoreConfig = data.backupId ? { backupId: data.backupId, backupFormat: backupInfo.format, oldManifest: app.manifest } : null; // when null, apptask simply reinstalls
scheduleTask(appId, { restoreConfig }, values, function (error, result) {
scheduleTask(appId, { restoreConfig, overwriteDns: true }, values, function (error, result) {
if (error) return callback(error);
eventlog.add(eventlog.ACTION_APP_RESTORE, auditSource, { app: app, backupId: backupInfo.id, fromManifest: app.manifest, toManifest: backupInfo.manifest, taskId: result.taskId });
@@ -1376,7 +1377,8 @@ function clone(appId, data, user, auditSource, callback) {
domain = data.domain.toLowerCase(),
portBindings = data.portBindings || null,
backupId = data.backupId,
mailboxName = data.mailboxName || '';
mailboxName = data.mailboxName || '',
overwriteDns = 'overwriteDns' in data ? data.overwriteDns : false;
assert.strictEqual(typeof backupId, 'string');
assert.strictEqual(typeof location, 'string');
@@ -1438,7 +1440,7 @@ function clone(appId, data, user, auditSource, callback) {
const restoreConfig = { backupId: backupId, backupFormat: backupInfo.format };
scheduleTask(newAppId, { restoreConfig }, { installationState: exports.ISTATE_PENDING_CLONE }, function (error, result) {
scheduleTask(newAppId, { restoreConfig, overwriteDns }, { installationState: exports.ISTATE_PENDING_CLONE }, function (error, result) {
if (error) return callback(error);
const newApp = _.extend({}, data, { appStoreId, manifest, location, domain, portBindings });
@@ -1692,7 +1694,7 @@ function restoreInstalledApps(callback) {
appdb.update(app.id, { taskId: null }, function (error) { // clear any stale taskId
if (error) debug(`Error marking ${app.fqdn} for restore: ${JSON.stringify(error)}`);
scheduleTask(app.id, { restoreConfig }, { installationState: exports.ISTATE_PENDING_RESTORE }, () => iteratorDone()); // always succeed
scheduleTask(app.id, { restoreConfig, overwriteDns: true }, { installationState: exports.ISTATE_PENDING_RESTORE }, () => iteratorDone()); // always succeed
});
});
}, callback);