← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~cgrabowski/maas:fix_glue_zones into maas:master

 

Christian Grabowski has proposed merging ~cgrabowski/maas:fix_glue_zones into maas:master.

Commit message:
use rndc freeze and thaw to allow BIND to handle receiving full reloads and dynamic updates more rapidly

ensure updates are only for the correct subnet



Requested reviews:
  MAAS Maintainers (maas-maintainers)
Related bugs:
  Bug #1999668 in MAAS: "[3.3.0~rc1-13133-g.67fd5b9af] reverse DNS not working for some interfaces"
  https://bugs.launchpad.net/maas/+bug/1999668

For more details, see:
https://code.launchpad.net/~cgrabowski/maas/+git/maas/+merge/436005
-- 
Your team MAAS Maintainers is requested to review the proposed merge of ~cgrabowski/maas:fix_glue_zones into maas:master.
diff --git a/src/maasserver/dns/tests/test_zonegenerator.py b/src/maasserver/dns/tests/test_zonegenerator.py
index 598074f..ee649a4 100644
--- a/src/maasserver/dns/tests/test_zonegenerator.py
+++ b/src/maasserver/dns/tests/test_zonegenerator.py
@@ -514,7 +514,9 @@ class TestZoneGenerator(MAASServerTestCase):
     def test_glue_receives_correct_dynamic_updates(self):
         domain = factory.make_Domain()
         subnet = factory.make_Subnet(cidr=str(IPNetwork("10/29").cidr))
+        other_subnet = factory.make_Subnet()
         sip = factory.make_StaticIPAddress(subnet=subnet)
+        other_sip = factory.make_StaticIPAddress(subnet=other_subnet)
         factory.make_Node_with_Interface_on_Subnet(
             subnet=subnet, vlan=subnet.vlan, fabric=subnet.vlan.fabric
         )
@@ -528,7 +530,14 @@ class TestZoneGenerator(MAASServerTestCase):
                 zone=domain.name,
                 rectype="A",
                 answer=sip.ip,
-            )
+            ),
+            DynamicDNSUpdate(
+                operation="INSERT",
+                name=update_rec.name,
+                zone=domain.name,
+                rectype="A",
+                answer=other_sip.ip,
+            ),
         ]
         zones = ZoneGenerator(
             domain,
diff --git a/src/maasserver/dns/zonegenerator.py b/src/maasserver/dns/zonegenerator.py
index 658147f..c165131 100644
--- a/src/maasserver/dns/zonegenerator.py
+++ b/src/maasserver/dns/zonegenerator.py
@@ -494,7 +494,12 @@ class ZoneGenerator:
                     ):
                         glue_update = False
                         break
-                if glue_update:
+                if (
+                    glue_update
+                    and update.answer
+                    and update.answer_is_ip
+                    and IPAddress(update.answer) in network
+                ):
                     domain_updates.append(
                         DynamicDNSUpdate.as_reverse_record_update(
                             update, str(network)
diff --git a/src/provisioningserver/dns/actions.py b/src/provisioningserver/dns/actions.py
index bafbac9..86a4274 100644
--- a/src/provisioningserver/dns/actions.py
+++ b/src/provisioningserver/dns/actions.py
@@ -50,6 +50,11 @@ def bind_reload(timeout=2):
     :return: True if success, False otherwise.
     """
     try:
+        # if first configuring a zone, we have to reload, but if already dynamically updated,
+        # BIND can use freeze / thaw so changes don't conflict with dynamic updates so both are done
+        # to load new zone data *and* config
+        execute_rndc_command(("freeze",), timeout=timeout)
+        execute_rndc_command(("thaw",), timeout=timeout)
         execute_rndc_command(("reload",), timeout=timeout)
         return True
     except CalledProcessError as exc:
diff --git a/src/provisioningserver/dns/tests/test_actions.py b/src/provisioningserver/dns/tests/test_actions.py
index 1087bc0..ddf6d45 100644
--- a/src/provisioningserver/dns/tests/test_actions.py
+++ b/src/provisioningserver/dns/tests/test_actions.py
@@ -74,9 +74,13 @@ class TestReload(MAASTestCase):
     def test_executes_rndc_command(self):
         self.patch_autospec(actions, "execute_rndc_command")
         actions.bind_reload()
-        self.assertThat(
-            actions.execute_rndc_command,
-            MockCalledOnceWith(("reload",), timeout=2),
+        self.assertCountEqual(
+            actions.execute_rndc_command.call_args_list,
+            [
+                call(("freeze",), timeout=2),
+                call(("thaw",), timeout=2),
+                call(("reload",), timeout=2),
+            ],
         )
 
     def test_logs_subprocess_error(self):

Follow ups