StackResource consider files in implementation_signature

Currently, if the definition of something changes further down
the tree (beyond the template in the StackResource itself in a
more deeply nested template, e.g a provider resource in a
provider resource), we don't recurse on update, so the changes
are not reflected correctly on update.

So modify the definition part of the StackResource implementation
signature so we include both the resource template and the files
map, so we recurse whenver the files content has changed.

Note, on upgrade the first stack update of nested stacks after
this change will update even if no changes have occurred, because
the signature will change.  This should be a no-op other than
the stacks going UPDATE_COMPLETE.

Change-Id: Iff3ecfbe410e47e31f78e111065888b7fd2ddd00
Partial-Bug: #1389499
This commit is contained in:
Steven Hardy 2014-11-18 16:12:54 +00:00
parent f5221feb8b
commit 32b4988ae5
2 changed files with 9 additions and 3 deletions

View File

@ -357,5 +357,7 @@ class StackResource(resource.Resource):
schema_names = ([prop for prop in self.properties_schema] +
[at for at in self.attributes_schema])
schema_hash = hashlib.sha1(';'.join(schema_names))
templ_hash = hashlib.sha1(jsonutils.dumps(self.child_template()))
return (schema_hash.hexdigest(), templ_hash.hexdigest())
definition = {'template': self.child_template(),
'files': self.stack.t.files}
definition_hash = hashlib.sha1(jsonutils.dumps(definition))
return (schema_hash.hexdigest(), definition_hash.hexdigest())

View File

@ -140,7 +140,11 @@ class StackResourceTest(common.HeatTestCase):
return_value=self.simple_template)
sig1, sig2 = self.parent_resource.implementation_signature()
self.assertEqual('3700dc2ae6ff4f0a236e7477ad6b8d51157f2153', sig1)
self.assertEqual('efe1707e1bd7dda17b9e995d8a8cf3c057119c96', sig2)
self.assertEqual('70e69545e0c47123159974c9166741085eb46dba', sig2)
self.parent_stack.t.files["foo"] = "bar"
sig1a, sig2a = self.parent_resource.implementation_signature()
self.assertEqual(sig1, sig1a)
self.assertNotEqual(sig2, sig2a)
def test_propagated_files(self):
self.parent_stack.t.files["foo"] = "bar"