Fix bug with designate-manage pool update losing existing record data

When designate-manage pool update is used we trigger an AFXR and
use that information to rebuild the zone. This is however only valid
for secondary zones, as the AXFR does not contain all the internal
information required for a primary zone and that causes designate to
lose important internal record data.

Closes-Bug: #2036750
Change-Id: I77a5d05cd8f55e975a16cb386221d53b63131886
(cherry picked from commit aaed97875c)
(cherry picked from commit f2624f73cf)
This commit is contained in:
Erik Olof Gunnar Andersson 2023-09-20 14:49:53 -07:00
parent f66ee1b26a
commit f9be4e2617
2 changed files with 37 additions and 1 deletions

View File

@ -1143,7 +1143,7 @@ class Service(service.RPCService):
context, zone, increment_serial=increment_serial)
# Fire off a XFR
if 'masters' in changes:
if zone.type == 'SECONDARY' and 'masters' in changes:
self.mdns_api.perform_zone_xfr(context, zone)
self.zone_api.update_zone(context, zone)

View File

@ -889,6 +889,42 @@ class CentralServiceTest(CentralTestCase):
self.assertIsInstance(notified_zone, objects.Zone)
self.assertEqual(zone.id, notified_zone.id)
def test_update_zone_master_for_primary_zone(self):
# Create a zone
zone = self.create_zone(email='info@example.org')
# Update the masters
zone.masters = objects.ZoneMasterList()
mdns = mock.Mock()
with mock.patch.object(mdns_api.MdnsAPI,
'get_instance') as get_worker:
get_worker.return_value = mdns
self.central_service.update_zone(self.admin_context, zone)
# Make sure we don't try to trigger an axfr for a primary zone.
self.assertFalse(mdns.perform_zone_xfr.called)
def test_update_zone_master_for_secondary_zone(self):
fixture = self.get_zone_fixture('SECONDARY', 0)
fixture['email'] = cfg.CONF['service:central'].managed_resource_email
fixture['masters'] = [{'host': '192.0.2.10', 'port': 53}]
# Create a zone
zone = self.create_zone(**fixture)
# Update the masters
zone.masters = objects.ZoneMasterList()
mdns = mock.Mock()
with mock.patch.object(mdns_api.MdnsAPI,
'get_instance') as get_mdns:
get_mdns.return_value = mdns
self.central_service.update_zone(self.admin_context, zone)
# Make sure we trigger an axfr for a secondary zone.
self.assertTrue(mdns.perform_zone_xfr.called)
def test_update_zone_without_id(self):
# Create a zone
zone = self.create_zone(email='info@example.org')