Andrew Bogott has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/360995 )
Change subject: wmf_sink: Clean up DNS for cleaned up proxies on instance
deletion.
......................................................................
wmf_sink: Clean up DNS for cleaned up proxies on instance deletion.
Bug: T168313
Change-Id: I3791b24370cb28d747c810f8ce4234c5c675681a
---
M modules/openstack/files/liberty/designate/wmf_sink/base.py
1 file changed, 31 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/95/360995/1
diff --git a/modules/openstack/files/liberty/designate/wmf_sink/base.py
b/modules/openstack/files/liberty/designate/wmf_sink/base.py
index c3a8ce1..74bd577 100644
--- a/modules/openstack/files/liberty/designate/wmf_sink/base.py
+++ b/modules/openstack/files/liberty/designate/wmf_sink/base.py
@@ -140,6 +140,37 @@
req = requests.delete(requrl + '/mapping/' + domain)
req.raise_for_status()
+ LOG.warning("We also need to delete the dns entry for %s" %
proxy)
+ self._delete_proxy_dns_record(proxy['domain'])
+
+ def _delete_proxy_dns_record(self, proxydomain):
+ if not proxydomain.endswith('.'):
+ proxydomain += '.'
+ context = DesignateContext().elevated()
+ context.all_tenants = True
+ context.edit_managed_records = True
+
+ parentdomain = '.'.join(proxydomain.split('.')[1:])
+ crit = {'name': parentdomain}
+
+ domainrecords = central_api.find_domains(context, crit)
+ if len(domainrecords) != 1:
+ LOG.warning("Unable to clean up this DNS proxy record. "
+ "Looked for domain %s and found %s" % (parentdomain,
+ domainrecords))
+ return
+
+ crit = {'domain_id': domainrecords[0].id, 'name': proxydomain}
+ recordsets = central_api.find_recordsets(context, crit)
+ if len(recordsets) != 1:
+ LOG.warning("Unable to clean up this DNS proxy record. "
+ "Looked for recordsets for %s and found %s"
(proxydomain,
+
recordsets))
+ return
+
+ LOG.warning("Deleting DNS entry for proxy: %s" % recordsets[0])
+ central_api.delete_recordset(context, domainrecords[0].id,
recordsets[0].id)
+
def _get_proxy_list_for_project(self, project):
endpoint = self._get_proxy_endpoint()
requrl = endpoint.replace("$(tenant_id)s", project)
--
To view, visit https://gerrit.wikimedia.org/r/360995
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3791b24370cb28d747c810f8ce4234c5c675681a
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits