Fix rollback failure when updating stack
When building oldstack in rollback, self.env doesn't match self.t, then the validating will fail, but oldstack is useless in rollback, so we don't need to build it in rollback. Change-Id: Iab17824d108d565126c1dd0338fefc9a5ee4f47b Closes-Bug: #1308883
This commit is contained in:
parent
78b68ba0da
commit
04bc6a5229
|
@ -644,8 +644,11 @@ class Stack(collections.Mapping):
|
|||
self.state_set(action, self.IN_PROGRESS,
|
||||
'Stack %s started' % action)
|
||||
|
||||
oldstack = Stack(self.context, self.name, copy.deepcopy(self.t),
|
||||
self.env)
|
||||
if action == self.UPDATE:
|
||||
# Oldstack is useless when the action is not UPDATE , so we don't
|
||||
# need to build it, this can avoid some unexpected errors.
|
||||
oldstack = Stack(self.context, self.name, copy.deepcopy(self.t),
|
||||
self.env)
|
||||
backup_stack = self._backup_stack()
|
||||
try:
|
||||
update_task = update.StackUpdate(self, newstack, backup_stack,
|
||||
|
|
|
@ -2342,24 +2342,30 @@ class StackTest(HeatTestCase):
|
|||
|
||||
def test_update_rollback_fail(self):
|
||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||
'Parameters': {'AParam': {'Type': 'String'}},
|
||||
'Resources': {'AResource': {'Type': 'ResourceWithPropsType',
|
||||
'Properties': {'Foo': 'abc'}}}}
|
||||
|
||||
env1 = {'parameters': {'AParam': 'abc'}}
|
||||
self.stack = parser.Stack(self.ctx, 'update_test_stack',
|
||||
template.Template(tmpl),
|
||||
disable_rollback=False)
|
||||
disable_rollback=False,
|
||||
env=environment.Environment(env1))
|
||||
self.stack.store()
|
||||
self.stack.create()
|
||||
self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
|
||||
tmpl2 = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||
'Parameters': {'BParam': {'Type': 'String'}},
|
||||
'Resources': {'AResource': {'Type': 'ResourceWithPropsType',
|
||||
'Properties': {'Foo': 'xyz'}}}}
|
||||
|
||||
env2 = {'parameters': {'BParam': 'smelly'}}
|
||||
updated_stack = parser.Stack(self.ctx, 'updated_stack',
|
||||
template.Template(tmpl2),
|
||||
disable_rollback=False)
|
||||
disable_rollback=False,
|
||||
env=environment.Environment(env2))
|
||||
|
||||
# patch in a dummy handle_create making the replace fail when creating
|
||||
# the replacement rsrc, and again on the second call (rollback)
|
||||
|
|
Loading…
Reference in New Issue