Secondary zone loops AXFR transfer during zone creation

When we create a secondary zone, AXFR transfer loops indefinitely.
Normally, only one xfr should be performed.
Due to AXFR loop the zone changes status from active to pending all the time.

Co-Authored-By: ZhouHeng <zhouhenglc@inspur.com>
Closes-Bug: 1856442
Change-Id: I0e0d138049e6d4c31dea3cc6768cc15e59a5942c
This commit is contained in:
Mitya_Eremeev 2022-11-09 20:09:12 +03:00 committed by Erik Olof Gunnar Andersson
parent f4ce71c8f8
commit 964562cc65
3 changed files with 40 additions and 2 deletions

View File

@ -821,7 +821,9 @@ class Service(service.RPCService):
self.worker_api.create_zone(context, zone)
if zone.type == 'SECONDARY':
self.worker_api.perform_zone_xfr(context, zone)
xfr_zone = copy.deepcopy(zone)
xfr_zone.obj_reset_changes(recursive=True)
self.worker_api.perform_zone_xfr(context, xfr_zone)
# If zone is a superzone, update subzones
# with new parent IDs

View File

@ -136,7 +136,7 @@ class DesignateObject(base.VersionedObject):
name == 'VERSION' or
name == 'fields'):
raise AttributeError(
"Designate object '%(type)s' has no"
"Designate object '%(type)s' has no "
"attribute '%(name)s'" % {
'type': self.obj_name(),
'name': name,

View File

@ -1609,6 +1609,42 @@ class CentralZoneTestCase(CentralBasic):
refresh_time = central_service._generate_soa_refresh_interval()
self.assertEqual(3563, refresh_time)
@patch.object(objects.Zone, 'obj_reset_changes')
def test_create_secondary_zone(self, mock_obj_reset_changes):
self.service._enforce_zone_quota = mock.Mock()
self.service._create_zone_in_storage = mock.Mock(
return_value=objects.Zone(name='example.com.', type='SECONDARY'))
self.service._is_valid_zone_name = mock.Mock()
self.service._is_valid_ttl = mock.Mock()
self.service._is_subzone = mock.Mock(return_value=False)
self.service._is_superzone = mock.Mock(return_value=[])
self.service.storage.get_pool.return_value = RoObject(
ns_records=[RoObject()])
self.useFixture(
fixtures.MockPatchObject(
self.service.storage,
'find_pools',
return_value=objects.PoolList.from_list(
[
{'id': '94ccc2c1-d751-44fe-b57f-8894c9f5c842'}
]
)
)
)
output = self.service.create_zone(
self.context,
objects.Zone(
tenant_id='1',
name='example.com.',
ttl=60,
pool_id=CentralZoneTestCase.pool__id,
refresh=0,
type='SECONDARY'
)
)
self.assertEqual('example.com.', output.name)
mock_obj_reset_changes.assert_called_once_with(recursive=True)
class IsSubzoneTestCase(CentralBasic):
def setUp(self):