Don't use cast() to do StackResource delete

If an exception was raised in delete_stack when deleting a nested stack,
the parent stack would never hear about it because we were accidentally
using cast() instead of call() to do the stack delete. This meant the
parent resource would remain DELETE_IN_PROGRESS until timeout when the
nested stack had already failed and raised an exception.

In the case of bug 1499669, the exception being missed was
StopActionFailed.

Change-Id: I039eb8f6c6a262653c1e9edc8173e5680d81e31b
Partial-Bug: #1499669
(cherry picked from commit e5cec71e52)
This commit is contained in:
Zane Bitter 2016-09-21 18:37:04 -04:00
parent 55a4aad7f9
commit a96d89b200
4 changed files with 7 additions and 5 deletions

View File

@ -524,9 +524,10 @@ class StackResource(resource.Resource):
if self.abandon_in_progress:
self.rpc_client().abandon_stack(self.context, stack_identity)
else:
self.rpc_client().delete_stack(self.context, stack_identity)
self.rpc_client().delete_stack(self.context, stack_identity,
cast=False)
except Exception as ex:
self.rpc_client().ignore_error_named(ex, 'NotFound')
self.rpc_client().ignore_error_named(ex, 'EntityNotFound')
def handle_delete(self):
return self.delete_nested()

View File

@ -413,4 +413,4 @@ Outputs:
self.res.nested().identifier.return_value = stack_identity
self.res.handle_delete()
self.res.rpc_client.return_value.delete_stack.assert_called_once_with(
self.ctx, self.res.nested().identifier())
self.ctx, self.res.nested().identifier(), cast=False)

View File

@ -1021,4 +1021,5 @@ class TemplateResourceCrudTest(common.HeatTestCase):
rpcc = self.res.rpc_client.return_value
rpcc.delete_stack.assert_called_once_with(
self.ctx,
self.res.nested().identifier())
self.res.nested().identifier(),
cast=False)

View File

@ -514,7 +514,7 @@ class StackResourceTest(StackResourceBaseTest):
side_effect=exception.NotFound())
self.assertIsNone(self.parent_resource.delete_nested())
rpcc.return_value.delete_stack.assert_called_once_with(
self.parent_resource.context, mock.ANY)
self.parent_resource.context, mock.ANY, cast=False)
def test_need_update_for_nested_resource(self):
"""Test the resource with nested stack should need update.