From 45e85e4d53e2c48ed5f430ac5e4483733ce4e7be Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 26 Sep 2019 22:30:58 -0700 Subject: [PATCH] Set overwriteDns to be true when re-configuring --- src/apps.js | 2 +- src/apptask.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/apps.js b/src/apps.js index 2f60d3697..429b2a978 100644 --- a/src/apps.js +++ b/src/apps.js @@ -1880,7 +1880,7 @@ function configureInstalledApps(callback) { const oldConfig = _.pick(app, 'location', 'domain', 'fqdn', 'alternateDomains', 'portBindings'); const task = { - args: { oldConfig }, + args: { oldConfig, overwriteDns: true }, values: {}, scheduleNow: false, // task will be scheduled by autoRestartTasks when platform is ready requireNullTaskId: false // ignore existing stale taskId diff --git a/src/apptask.js b/src/apptask.js index c8e7bab46..3bb546286 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -667,6 +667,7 @@ function changeLocation(app, args, progressCallback, callback) { const oldConfig = args.oldConfig; const locationChanged = oldConfig.fqdn !== app.fqdn; + const overwriteDns = args.overwriteDns; async.series([ progressCallback.bind(null, { percent: 10, message: 'Cleaning up old install' }), @@ -686,7 +687,7 @@ function changeLocation(app, args, progressCallback, callback) { }, progressCallback.bind(null, { percent: 30, message: 'Registering subdomains' }), - registerSubdomains.bind(null, app, args.overwriteDns), + registerSubdomains.bind(null, app, overwriteDns), // re-setup addons since they rely on the app's fqdn (e.g oauth) progressCallback.bind(null, { percent: 50, message: 'Setting up addons' }), @@ -767,6 +768,9 @@ function configure(app, args, progressCallback, callback) { assert.strictEqual(typeof progressCallback, 'function'); assert.strictEqual(typeof callback, 'function'); + const oldConfig = args.oldConfig || null; + const overwriteDns = args.overwriteDns; + async.series([ progressCallback.bind(null, { percent: 10, message: 'Cleaning up old install' }), unconfigureReverseProxy.bind(null, app), @@ -775,13 +779,13 @@ function configure(app, args, progressCallback, callback) { docker.stopContainers.bind(null, app.id), deleteContainers.bind(null, app, { managedOnly: true }), function (next) { - if (!args.oldConfig) return next(); + if (!oldConfig) return next(); - let obsoleteDomains = args.oldConfig.alternateDomains.filter(function (o) { + let obsoleteDomains = oldConfig.alternateDomains.filter(function (o) { return !app.alternateDomains.some(function (n) { return n.subdomain === o.subdomain && n.domain === o.domain; }); }); - if (args.oldConfig.fqdn !== app.fqdn) obsoleteDomains.push({ subdomain: args.oldConfig.location, domain: args.oldConfig.domain }); + if (oldConfig.fqdn !== app.fqdn) obsoleteDomains.push({ subdomain: oldConfig.location, domain: oldConfig.domain }); if (obsoleteDomains.length === 0) return next(); @@ -794,7 +798,7 @@ function configure(app, args, progressCallback, callback) { downloadIcon.bind(null, app), progressCallback.bind(null, { percent: 30, message: 'Registering subdomains' }), - registerSubdomains.bind(null, app, false /* overwrite */), // if location changed, do not overwrite to detect conflicts + registerSubdomains.bind(null, app, overwriteDns), progressCallback.bind(null, { percent: 40, message: 'Downloading image' }), downloadImage.bind(null, app.manifest),