Don't delete trust on backup stack delete
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 8ce9a177c4
)
Conflicts:
heat/engine/parser.py
Change-Id: I578d4e373d425cc0452ae235637cc50bac455433
This commit is contained in:
parent
6c99dc46c5
commit
527009d0e4
|
@ -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)
|
||||
|
|
|
@ -820,6 +820,33 @@ class StackTest(HeatTestCase):
|
|||
self.assertEqual(self.stack.state,
|
||||
(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')
|
||||
|
|
Loading…
Reference in New Issue