Browse Source

Ignore dns domain NotFound when deleting record

when the domain is deleted, all its records are deleted as well.
Not ignoring such NotFound can lead to undeletable stacks if they
have a Designate::Record resource that references a deleted Designate
Domain.

Change-Id: If56f84b0b86f4d8136a1f83683a4a9eee5d89759
Closes-Bug: #1748953
changes/85/543585/1
Pavlo Shchelokovskyy 4 years ago
parent
commit
55a7492c6c
  1. 5
      heat/engine/clients/os/designate.py
  2. 18
      heat/tests/clients/test_designate_client.py

5
heat/engine/clients/os/designate.py

@ -97,7 +97,10 @@ class DesignateClientPlugin(client_plugin.ClientPlugin):
return self.client().records.update(record.domain_id, record)
def record_delete(self, **kwargs):
domain_id = self.get_domain_id(kwargs.pop('domain'))
try:
domain_id = self.get_domain_id(kwargs.pop('domain'))
except heat_exception.EntityNotFound:
return
return self.client().records.delete(domain_id,
kwargs.pop('id'))

18
heat/tests/clients/test_designate_client.py

@ -283,6 +283,24 @@ class DesignateClientPluginRecordTest(common.HeatTestCase):
self.sample_domain_id,
self.sample_uuid)
@mock.patch.object(client.DesignateClientPlugin, 'client')
@mock.patch('designateclient.v1.records.Record')
def test_record_delete_domain_not_found(self, mock_record,
client_designate):
self._client.records.delete.return_value = None
self.client_plugin.get_domain_id.side_effect = (
heat_exception.EntityNotFound)
client_designate.return_value = self._client
record = dict(
id=self.sample_uuid,
domain=self.sample_domain_id
)
self.client_plugin.record_delete(**record)
self.assertFalse(self._client.records.delete.called)
@mock.patch.object(client.DesignateClientPlugin, 'client')
@mock.patch('designateclient.v1.records.Record')
def test_record_show(self, mock_record, client_designate):

Loading…
Cancel
Save