diff --git a/src/apptask.js b/src/apptask.js index e384a901a..5a3b44876 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -268,12 +268,10 @@ function unregisterSubdomain(app, location, callback) { return callback(null); } - var record = { subdomain: location, type: 'A', value: sysinfo.getIp() }; - async.retry({ times: 30, interval: 5000 }, function (retryCallback) { debugApp(app, 'Unregistering subdomain: %s', location); - subdomains.remove(record, function (error) { + subdomains.remove(location, 'A', [ sysinfo.getIp() ], function (error) { if (error && (error.reason === SubdomainError.STILL_BUSY || error.reason === SubdomainError.EXTERNAL_ERROR)) return retryCallback(error); // try again retryCallback(null, error); diff --git a/src/dns/caas.js b/src/dns/caas.js index e11d320dc..77dc40d81 100644 --- a/src/dns/caas.js +++ b/src/dns/caas.js @@ -4,7 +4,7 @@ exports = module.exports = { add: add, - delSubdomain: delSubdomain, + del: del, updateSubdomain: updateSubdomain, getChangeStatus: getChangeStatus, get: get @@ -54,7 +54,7 @@ function get(zoneName, subdomain, type, callback) { var fqdn = subdomain !== '' && type === 'TXT' ? subdomain + '.' + config.fqdn() : config.appFqdn(subdomain); - debug('getSubdomain: zoneName: %s subdomain: %s type: %s fqdn: %s', zoneName, subdomain, type, fqdn); + debug('get: zoneName: %s subdomain: %s type: %s fqdn: %s', zoneName, subdomain, type, fqdn); superagent .get(config.apiServerOrigin() + '/api/v1/domains/' + fqdn) @@ -83,18 +83,18 @@ function updateSubdomain(zoneName, subdomain, type, value, callback) { }); } -function delSubdomain(zoneName, subdomain, type, value, callback) { +function del(zoneName, subdomain, type, values, callback) { assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof subdomain, 'string'); assert.strictEqual(typeof type, 'string'); - assert.strictEqual(typeof value, 'string'); + assert(util.isArray(values)); assert.strictEqual(typeof callback, 'function'); - debug('delSubdomain: %s for domain %s.', subdomain, zoneName); + debug('add: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values); var data = { type: type, - values: [ value ] + values: values }; superagent diff --git a/src/dns/route53.js b/src/dns/route53.js index 77db4a5f0..3707ac816 100644 --- a/src/dns/route53.js +++ b/src/dns/route53.js @@ -5,7 +5,7 @@ exports = module.exports = { add: add, get: get, - delSubdomain: delSubdomain, + del: del, updateSubdomain: updateSubdomain, getChangeStatus: getChangeStatus }; @@ -155,16 +155,14 @@ function get(zoneName, subdomain, type, callback) { }); } -function delSubdomain(zoneName, subdomain, type, value, callback) { +function del(zoneName, subdomain, type, values, callback) { assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof subdomain, 'string'); assert.strictEqual(typeof type, 'string'); - assert.strictEqual(typeof value, 'string'); + assert(util.isArray(values)); assert.strictEqual(typeof callback, 'function'); - debug('delSubdomain: %s for domain %s.', subdomain, zoneName); - - var values = [ value ]; + debug('add: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values); getZoneByName(zoneName, function (error, zone) { if (error) return callback(error); diff --git a/src/subdomains.js b/src/subdomains.js index 45db20334..500dfdd5b 100644 --- a/src/subdomains.js +++ b/src/subdomains.js @@ -62,17 +62,14 @@ function update(record, callback) { }); } -function remove(record, callback) { - assert.strictEqual(typeof record, 'object'); - assert.strictEqual(typeof callback, 'function'); +function remove(subdomain, type, values, callback) { + assert.strictEqual(typeof subdomain, 'string'); + assert.strictEqual(typeof type, 'string'); + assert(util.isArray(values)); - debug('remove: ', record); - - api().delSubdomain(config.zoneName(), record.subdomain, record.type, record.value, function (error) { + api().del(config.zoneName(), subdomain, type, values, function (error) { if (error && error.reason !== SubdomainError.NOT_FOUND) return callback(error); - debug('deleteSubdomain: successfully deleted %j', record); - callback(null); }); }