Fix handle_delete for zaqar queue

Now the call to client.queue() is wrapped in try-except clause,
but actually queue() doesn't make any calls to api and can't rise
any exception. Such behaviour can lead to UPDDATE_FAILED state of the
stack if the queue will not exist. Try to delete queue and then catch
appropriate exception.

Change-Id: I484bae099e3236d6b00ec5b3c2c562d971b7463e
This commit is contained in:
Oleksii Chuprykov 2015-08-04 16:48:13 +03:00
parent 8ebf25546c
commit 1369989db7
2 changed files with 4 additions and 4 deletions

View File

@ -106,11 +106,9 @@ class ZaqarQueue(resource.Resource):
if not self.resource_id:
return
try:
queue = self.client().queue(self.resource_id, auto_create=False)
self.client().queue(self.resource_id, auto_create=False).delete()
except Exception as exc:
self.client_plugin().ignore_not_found(exc)
else:
queue.delete()
def href(self):
api_endpoint = self.client().api_url

View File

@ -200,7 +200,9 @@ class ZaqarMessageQueueTest(common.HeatTestCase):
mock_stack = mock.Mock()
mock_stack.db_resource_get.return_value = None
mockclient.return_value.queue.side_effect = ResourceNotFound
zaqar_q = mock.Mock()
zaqar_q.delete.side_effect = ResourceNotFound
mockclient.return_value.queue.return_value = zaqar_q
mockplugin.return_value.ignore_not_found.return_value = None
zplugin = queue.ZaqarQueue("test_delete_not_found", mock_def,
mock_stack)