summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-04-20 21:07:02 +0000
committerGerrit Code Review <review@openstack.org>2023-04-20 21:07:02 +0000
commit38b100a6fb775ab5f1b566294b2c2d72f889300f (patch)
tree6981f5d51891612c7ff4ab40e177b16536c348ae
parente354126d7ae7463930be11206a9566b5d5fd8691 (diff)
parent1c7344d71160ee0d2c55ad51ba9a2024c8e98b1d (diff)
downloaddesignate-stable/2023.1.tar.gz
Merge "Use ids when removing ptr records" into stable/2023.1stable/2023.1
-rw-r--r--designate/central/service.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/designate/central/service.py b/designate/central/service.py
index 7772a925..b51c8d81 100644
--- a/designate/central/service.py
+++ b/designate/central/service.py
@@ -1846,7 +1846,8 @@ class Service(service.RPCService):
LOG.debug('Deleting record %s for FIP %s',
record['id'], record['managed_resource_id'])
self._delete_ptr_record(
- elevated_context, record
+ elevated_context, record.zone_id, record.recordset_id,
+ record['id']
)
def _list_floatingips(self, context, region=None):
@@ -2020,7 +2021,8 @@ class Service(service.RPCService):
raise exceptions.NotFound(msg)
self._delete_ptr_record(
- elevated_context, record
+ elevated_context, record.zone_id, record.recordset_id,
+ record['id']
)
def _create_floating_ip(self, context, fip, record,
@@ -2100,24 +2102,30 @@ class Service(service.RPCService):
return fips
@transaction
- def _delete_ptr_record(self, context, record):
+ def _delete_ptr_record(self, context, zone_id, recordset_id,
+ record_to_delete_id):
try:
- recordset = self.get_recordset(
- context, record.zone_id, record.recordset_id
+ recordset = self.storage.find_recordset(
+ context, {'id': recordset_id, 'zone_id': zone_id}
)
+ record_ids = [record['id'] for record in recordset.records]
- if record not in recordset.records:
+ if record_to_delete_id not in record_ids:
LOG.debug(
'PTR Record %s not found in recordset %s',
- record.id, record.recordset_id
+ record_to_delete_id, recordset_id
)
return
- recordset.records.remove(record)
+ for record in list(recordset.records):
+ if record['id'] != record_to_delete_id:
+ continue
+ recordset.records.remove(record)
+ break
if not recordset.records:
self.delete_recordset(
- context, record.zone_id, record.recordset_id
+ context, zone_id, recordset_id
)
return