summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2014-01-23 13:55:53 +0000
committerZhang Yang <neil.zhangyang@huawei.com>2014-03-13 01:55:12 -0700
commit527009d0e4a73481459a5246e898390fb432d612 (patch)
treeaca249b56235c2e3a438acde5075114f3b7ca783
parent6c99dc46c5d4ebe91c6da49ace286025e55b9a2d (diff)
downloadheat-527009d0e4a73481459a5246e898390fb432d612.tar.gz
Don't delete trust on backup stack delete2013.2.3
Since the trust_id is copied from the stack being backed-up, we don't want to delete the trust when the backup is deleted, or the actual stack will break when the next deferred auth operation occurs. Closes-Bug: #1271968 (cherry picked from commit 8ce9a177c47b3ee224200690d7181c784c418292) Conflicts: heat/engine/parser.py Change-Id: I578d4e373d425cc0452ae235637cc50bac455433
-rw-r--r--heat/engine/parser.py8
-rw-r--r--heat/tests/test_parser.py27
2 files changed, 31 insertions, 4 deletions
diff --git a/heat/engine/parser.py b/heat/engine/parser.py
index ba97e72c2..9ca186484 100644
--- a/heat/engine/parser.py
+++ b/heat/engine/parser.py
@@ -505,7 +505,7 @@ class Stack(object):
return
else:
logger.debug('Deleting backup stack')
- backup_stack.delete()
+ backup_stack.delete(backup=True)
self.state_set(action, stack_status, reason)
@@ -518,7 +518,7 @@ class Stack(object):
self.outputs = self.resolve_static_data(template_outputs)
self.store()
- def delete(self, action=DELETE):
+ def delete(self, action=DELETE, backup=False):
'''
Delete all of the resources, and then the stack itself.
The action parameter is used to differentiate between a user
@@ -538,7 +538,7 @@ class Stack(object):
backup_stack = self._backup_stack(False)
if backup_stack is not None:
- backup_stack.delete()
+ backup_stack.delete(backup=True)
if backup_stack.status != backup_stack.COMPLETE:
errs = backup_stack.status_reason
failure = 'Error deleting backup resources: %s' % errs
@@ -558,7 +558,7 @@ class Stack(object):
stack_status = self.FAILED
reason = '%s timed out' % action.title()
- if stack_status != self.FAILED:
+ if stack_status != self.FAILED and not backup:
# If we created a trust, delete it
stack = db_api.stack_get(self.context, self.id)
user_creds = db_api.user_creds_get(stack.user_creds_id)
diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py
index 8f15df975..bbd13d5ea 100644
--- a/heat/tests/test_parser.py
+++ b/heat/tests/test_parser.py
@@ -821,6 +821,33 @@ class StackTest(HeatTestCase):
(parser.Stack.DELETE, parser.Stack.COMPLETE))
@utils.stack_delete_after
+ def test_delete_trust_backup(self):
+ cfg.CONF.set_override('deferred_auth_method', 'trusts')
+
+ class FakeKeystoneClientFail(FakeKeystoneClient):
+ def delete_trust(self, trust_id):
+ raise Exception("Shouldn't delete")
+
+ self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
+ clients.OpenStackClients.keystone().MultipleTimes().AndReturn(
+ FakeKeystoneClientFail())
+ self.m.ReplayAll()
+
+ self.stack = parser.Stack(
+ self.ctx, 'delete_trust', template.Template({}))
+ stack_id = self.stack.store()
+
+ db_s = db_api.stack_get(self.ctx, stack_id)
+ self.assertIsNotNone(db_s)
+
+ self.stack.delete(backup=True)
+
+ db_s = db_api.stack_get(self.ctx, stack_id)
+ self.assertIsNone(db_s)
+ self.assertEqual(self.stack.state,
+ (parser.Stack.DELETE, parser.Stack.COMPLETE))
+
+ @utils.stack_delete_after
def test_delete_trust_fail(self):
cfg.CONF.set_override('deferred_auth_method', 'trusts')