summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Herve <therve@redhat.com>2015-11-12 17:35:07 +0100
committerZane Bitter <zbitter@redhat.com>2015-11-19 19:57:16 +0000
commitb94eb8f072cf39e3ac28fdd50dee1af3eea07752 (patch)
tree564be6226a498e9b9b72bd46ca6cc29ad097f069
parent4c85c14045d09280556b6f6821c14ce4044f0ae0 (diff)
downloadheat-b94eb8f072cf39e3ac28fdd50dee1af3eea07752.tar.gz
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 commit 88da460316e2c18b3ceb58f51dcf0bda717a18a3 and 13c68910704844719b2d3de353d2db276377bf11)
-rwxr-xr-xheat/engine/stack.py2
-rw-r--r--heat_integrationtests/functional/test_create_update.py32
2 files changed, 34 insertions, 0 deletions
diff --git a/heat/engine/stack.py b/heat/engine/stack.py
index ea1ee9ae9..dd3306345 100755
--- a/heat/engine/stack.py
+++ b/heat/engine/stack.py
@@ -980,6 +980,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,
newstack, action,
diff --git a/heat_integrationtests/functional/test_create_update.py b/heat_integrationtests/functional/test_create_update.py
index 37b179084..df7f3af2b 100644
--- a/heat_integrationtests/functional/test_create_update.py
+++ b/heat_integrationtests/functional/test_create_update.py
@@ -384,3 +384,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))