diff options
author | Ethan Lynn <xjunlin@cn.ibm.com> | 2015-04-02 23:40:17 +0800 |
---|---|---|
committer | Ethan Lynn <xjunlin@cn.ibm.com> | 2015-04-02 23:40:17 +0800 |
commit | 189324a7094dc84d8b8206df38e754ae07daf1e4 (patch) | |
tree | e69982a45751da1ecfe6661208788b7539164785 | |
parent | f65079fe74b82efe3662b13cdc4c61e25639b625 (diff) | |
download | heat-189324a7094dc84d8b8206df38e754ae07daf1e4.tar.gz |
Fix stack update issue
Different type of resource with same name should consider to be a
new resource when stack-update.
Change-Id: I102ffbd1a1562c164f43969c87570096c280738a
Closes-Bug: #1404201
-rw-r--r-- | heat/engine/update.py | 4 | ||||
-rw-r--r-- | heat/tests/test_stack_update.py | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/heat/engine/update.py b/heat/engine/update.py index 4683223ca..67d4fda83 100644 --- a/heat/engine/update.py +++ b/heat/engine/update.py @@ -124,8 +124,10 @@ class StackUpdate(object): @scheduler.wrappertask def _process_new_resource_update(self, new_res): res_name = new_res.name + res_type = new_res.type() - if res_name in self.existing_stack: + if (res_name in self.existing_stack and + res_type == self.existing_stack[res_name].type()): existing_res = self.existing_stack[res_name] try: yield self._update_in_place(existing_res, diff --git a/heat/tests/test_stack_update.py b/heat/tests/test_stack_update.py index 4867979d8..7be51c9c5 100644 --- a/heat/tests/test_stack_update.py +++ b/heat/tests/test_stack_update.py @@ -89,6 +89,32 @@ class StackUpdateTest(common.HeatTestCase): self.stack.state) self.assertNotIn('BResource', self.stack) + def test_update_different_type(self): + tmpl = {'HeatTemplateFormatVersion': '2012-12-12', + 'Resources': { + 'AResource': {'Type': 'GenericResourceType'}}} + + self.stack = stack.Stack(self.ctx, 'update_test_stack', + template.Template(tmpl)) + self.stack.store() + self.stack.create() + self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE), + self.stack.state) + self.assertEqual('GenericResourceType', + self.stack['AResource'].type()) + + tmpl2 = {'HeatTemplateFormatVersion': '2012-12-12', + 'Resources': {'AResource': {'Type': 'ResourceWithPropsType', + 'Properties': {'Foo': 'abc'}}}} + + updated_stack = stack.Stack(self.ctx, 'updated_stack', + template.Template(tmpl2)) + self.stack.update(updated_stack) + self.assertEqual((stack.Stack.UPDATE, stack.Stack.COMPLETE), + self.stack.state) + self.assertEqual('ResourceWithPropsType', + self.stack['AResource'].type()) + def test_update_description(self): tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Description': 'ATemplate', |