From e5cec71e52c3fed0ffb4385990758db8ebf367da Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Wed, 21 Sep 2016 18:37:04 -0400 Subject: [PATCH] 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 --- heat/engine/resources/stack_resource.py | 5 +++-- heat/tests/test_nested_stack.py | 2 +- heat/tests/test_provider_template.py | 3 ++- heat/tests/test_stack_resource.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/heat/engine/resources/stack_resource.py b/heat/engine/resources/stack_resource.py index 751c6c159..2978879a9 100644 --- a/heat/engine/resources/stack_resource.py +++ b/heat/engine/resources/stack_resource.py @@ -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() diff --git a/heat/tests/test_nested_stack.py b/heat/tests/test_nested_stack.py index 77d5d4081..24c8eaf12 100644 --- a/heat/tests/test_nested_stack.py +++ b/heat/tests/test_nested_stack.py @@ -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) diff --git a/heat/tests/test_provider_template.py b/heat/tests/test_provider_template.py index 7e48f341c..6148681c6 100644 --- a/heat/tests/test_provider_template.py +++ b/heat/tests/test_provider_template.py @@ -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) diff --git a/heat/tests/test_stack_resource.py b/heat/tests/test_stack_resource.py index f8e506ce8..c809d27d8 100644 --- a/heat/tests/test_stack_resource.py +++ b/heat/tests/test_stack_resource.py @@ -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.