Copy the env to the backup stack in failed update
When an update fails, we currently update the environment of the stack to contain both the new and old parameters and types. Unfortunately we don't do that for the backup stack which is reused. This patch adds the environment change. Change-Id: I4dc5dd35e4aeee498dd8960a1000913e97b924d5 Closes-Bug: 1508096 (cherry picked from commit88da460316
and13c6891070
)
This commit is contained in:
parent
531e6ce308
commit
fde608d0b5
|
@ -1250,6 +1250,8 @@ class Stack(collections.Mapping):
|
|||
existing_params.load(newstack.t.env.user_env_as_dict())
|
||||
self.t.env = existing_params
|
||||
self.t.store(self.context)
|
||||
backup_stack.t.env = existing_params
|
||||
backup_stack.t.store(self.context)
|
||||
self.store()
|
||||
|
||||
lifecycle_plugin_utils.do_post_ops(self.context, self,
|
||||
|
|
|
@ -513,3 +513,35 @@ resources:
|
|||
stack_identifier,
|
||||
template=self.update_userdata_template,
|
||||
parameters=parms_updated)
|
||||
|
||||
def test_stack_update_with_new_env(self):
|
||||
"""Update handles new resource types in the environment.
|
||||
|
||||
If a resource type appears during an update and the update fails,
|
||||
retrying the update is able to find the type properly in the
|
||||
environment.
|
||||
"""
|
||||
stack_identifier = self.stack_create(
|
||||
template=test_template_one_resource)
|
||||
|
||||
# Update with a new resource and make the update fails
|
||||
template = _change_rsrc_properties(test_template_one_resource,
|
||||
['test1'], {'fail': True})
|
||||
template['resources']['test2'] = {'type': 'My::TestResource'}
|
||||
template['resources']['test1']['depends_on'] = 'test2'
|
||||
env = {'resource_registry':
|
||||
{'My::TestResource': 'OS::Heat::TestResource'}}
|
||||
self.update_stack(stack_identifier,
|
||||
template=template,
|
||||
environment=env,
|
||||
expected_status='UPDATE_FAILED')
|
||||
|
||||
# Fixing the template should fix the stack
|
||||
template = _change_rsrc_properties(template,
|
||||
['test1'], {'fail': False})
|
||||
self.update_stack(stack_identifier,
|
||||
template=template,
|
||||
environment=env)
|
||||
self.assertEqual({'test1': 'OS::Heat::TestResource',
|
||||
'test2': 'My::TestResource'},
|
||||
self.list_resources(stack_identifier))
|
||||
|
|
Loading…
Reference in New Issue