Merge "Fix stack update issue"

This commit is contained in:
Jenkins 2015-04-07 04:56:49 +00:00 committed by Gerrit Code Review
commit d56778dc7a
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',