summaryrefslogtreecommitdiff
path: root/designate/backend/impl_bind9.py
diff options
context:
space:
mode:
authorJorge Niedbalski <jorge.niedbalski@canonical.com>2020-05-28 14:57:49 -0400
committerNicolas Bock <nicolas.bock@canonical.com>2021-04-23 13:31:08 -0600
commit0b5634643b4b69cd0a7d5499f258602604741d22 (patch)
treeb713bf09655041ebaec882711746786bcaf6fdb8 /designate/backend/impl_bind9.py
parentacc82755f1e8df8bb8f0ab7b4524f691637a312e (diff)
downloaddesignate-stable/stein.tar.gz
Update zones masters using pool target masters.stein-eolstable/stein
This change enforces the update of the zone masters for all zones that belongs to a particular pool, using the pool's defined target(s) masters and forcing a update_zone call. This change also, moves the backend base class update_zone method as an abstract method, allowing to each backend implementation to create its own update logic. For the case of bind9 its extended to allow running a rndc modzone with the new given masters for the zone fixing the behavior exposed on LP: #1879798. Fixes-Bug: #1879798 Change-Id: I9dddd4130a0cbb29311eeb52e077e216c8c03f3a Signed-off-by: Jorge Niedbalski <jorge.niedbalski@canonical.com> Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com> (cherry picked from commit 3756fc51e71aaf0ba7cfb9155ca5d1de26ab78bc)
Diffstat (limited to 'designate/backend/impl_bind9.py')
-rw-r--r--designate/backend/impl_bind9.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/designate/backend/impl_bind9.py b/designate/backend/impl_bind9.py
index aead79f7..6737ae4e 100644
--- a/designate/backend/impl_bind9.py
+++ b/designate/backend/impl_bind9.py
@@ -125,6 +125,43 @@ class Bind9Backend(base.Backend):
if "not found" not in six.text_type(e):
raise
+ def update_zone(self, context, zone):
+ """
+ Update a DNS zone.
+
+ This will execute a rndc modzone as the zone
+ already exists but masters might need to be refreshed.
+
+ :param context: Security context information.
+ :param zone: the DNS zone.
+ """
+ LOG.debug('Update Zone')
+
+ masters = []
+ for master in self.masters:
+ host = master['host']
+ port = master['port']
+ masters.append('%s port %s' % (host, port))
+
+ # Ensure different MiniDNS instances are targeted for AXFRs
+ random.shuffle(masters)
+
+ view = 'in %s' % self._view if self._view else ''
+
+ rndc_op = [
+ 'modzone',
+ '%s %s { type slave; masters { %s;}; file "slave.%s%s"; };' %
+ (zone['name'].rstrip('.'), view, '; '.join(masters), zone['name'],
+ zone['id']),
+ ]
+
+ try:
+ self._execute_rndc(rndc_op)
+ except exceptions.Backend as e:
+ LOG.warning("Error updating zone: %s", e)
+ pass
+ super(Bind9Backend, self).update_zone(context, zone)
+
def _execute_rndc(self, rndc_op):
"""Execute rndc