Use ids when removing ptr records
If the record status changes during the removal process, the current implementation will fail. Change-Id: I02b5d7499440154160c89ed63a2f70652fe72145
This commit is contained in:
parent
f4ce71c8f8
commit
b3161ece23
@ -1845,7 +1845,8 @@ class Service(service.RPCService):
|
|||||||
LOG.debug('Deleting record %s for FIP %s',
|
LOG.debug('Deleting record %s for FIP %s',
|
||||||
record['id'], record['managed_resource_id'])
|
record['id'], record['managed_resource_id'])
|
||||||
self._delete_ptr_record(
|
self._delete_ptr_record(
|
||||||
elevated_context, record
|
elevated_context, record.zone_id, record.recordset_id,
|
||||||
|
record['id']
|
||||||
)
|
)
|
||||||
|
|
||||||
def _list_floatingips(self, context, region=None):
|
def _list_floatingips(self, context, region=None):
|
||||||
@ -2019,7 +2020,8 @@ class Service(service.RPCService):
|
|||||||
raise exceptions.NotFound(msg)
|
raise exceptions.NotFound(msg)
|
||||||
|
|
||||||
self._delete_ptr_record(
|
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,
|
def _create_floating_ip(self, context, fip, record,
|
||||||
@ -2099,24 +2101,30 @@ class Service(service.RPCService):
|
|||||||
return fips
|
return fips
|
||||||
|
|
||||||
@transaction
|
@transaction
|
||||||
def _delete_ptr_record(self, context, record):
|
def _delete_ptr_record(self, context, zone_id, recordset_id,
|
||||||
|
record_to_delete_id):
|
||||||
try:
|
try:
|
||||||
recordset = self.get_recordset(
|
recordset = self.storage.find_recordset(
|
||||||
context, record.zone_id, record.recordset_id
|
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(
|
LOG.debug(
|
||||||
'PTR Record %s not found in recordset %s',
|
'PTR Record %s not found in recordset %s',
|
||||||
record.id, record.recordset_id
|
record_to_delete_id, recordset_id
|
||||||
)
|
)
|
||||||
return
|
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:
|
if not recordset.records:
|
||||||
self.delete_recordset(
|
self.delete_recordset(
|
||||||
context, record.zone_id, record.recordset_id
|
context, zone_id, recordset_id
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user