From a33f761f477222c5df1c11b207fdf75b17098bd8 Mon Sep 17 00:00:00 2001 From: Nakul Dahiwade Date: Tue, 19 Jun 2018 22:13:14 +0000 Subject: [PATCH] delete_trust failure will not block a stack delete Deleting a tenant that has active stacks would have to issue a stack delete twice per stack to delete those stacks, that was because the delete_trust would fail, but credentials were still cleared.This change just logs the error but does not fail the stack delete. Change-Id: I9d770a91b20d1db137b3fc313c794fcee4a5e4bf Story: 2002619 Task: 22248 --- heat/engine/stack.py | 8 +++++--- heat/tests/test_stack_delete.py | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/heat/engine/stack.py b/heat/engine/stack.py index 31c3b7b42f..20248fdd5d 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -1787,10 +1787,12 @@ class Stack(collections.Mapping): self.clients.client('keystone').delete_trust( trust_id) except Exception as ex: + # We want the admin to be able to delete the stack + # Do not FAIL a delete when we cannot delete a trust. + # We already carry through and delete the credentials + # Without this, they would need to issue + # an additional stack-delete LOG.exception("Error deleting trust") - stack_status = self.FAILED - reason = ("Error deleting trust: %s" % - six.text_type(ex)) # Delete the stored credentials try: diff --git a/heat/tests/test_stack_delete.py b/heat/tests/test_stack_delete.py index a24cc14a5e..6b07ce0b24 100644 --- a/heat/tests/test_stack_delete.py +++ b/heat/tests/test_stack_delete.py @@ -354,10 +354,9 @@ class StackTest(common.HeatTestCase): self.assertEqual(2, mock_kcp.call_count) db_s = stack_object.Stack.get_by_id(self.ctx, stack_id) - self.assertIsNotNone(db_s) - self.assertEqual((stack.Stack.DELETE, stack.Stack.FAILED), + self.assertIsNone(db_s) + self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE), self.stack.state) - self.assertIn('Error deleting trust', self.stack.status_reason) def test_delete_deletes_project(self): fkc = fake_ks.FakeKeystoneClient()