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
This commit is contained in:
Ethan Lynn 2015-04-02 23:40:17 +08:00
parent f65079fe74
commit 189324a709
2 changed files with 29 additions and 1 deletions

View File

@ -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,

View File

@ -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',