Work around parameter error deleting backup stack

There is a problem where restoring a backup resource which references
a parameter in it's properties that doesn't exist in the backup stack
will fail to delete, if the property is referenced in the delete path
of the resource.

We can work around the problem by always returning the frozen_definition
properties on delete, provided there are stored properties to refer to.

Closes-Bug: #1494260
Change-Id: I462ce7161497306483286b78416f9037ac80d6fa
This commit is contained in:
Steven Hardy 2015-09-14 11:38:48 +01:00
parent 1397af1b6d
commit fc77e43297
4 changed files with 16 additions and 1 deletions

View File

@ -1186,6 +1186,12 @@ class Resource(object):
LOG.info(_LI('deleting %s'), six.text_type(self))
if self._stored_properties_data is not None:
# On delete we can't rely on re-resolving the properties
# so use the stored frozen_definition instead
self.properties = self.frozen_definition().properties(
self.properties_schema, self.context)
with self._action_recorder(action):
if self.abandon_in_progress:
deletion_policy = self.t.RETAIN

View File

@ -143,6 +143,8 @@ class HeatTestCase(testscenarios.WithScenarios,
generic_rsrc.SignalResource)
resource._register_class('ResourceWithPropsType',
generic_rsrc.ResourceWithProps)
resource._register_class('ResourceWithPropsRefPropOnDelete',
generic_rsrc.ResourceWithPropsRefPropOnDelete)
resource._register_class('StackUserResourceType',
generic_rsrc.StackUserResource)
resource._register_class('ResourceWithResourceIDType',

View File

@ -97,6 +97,11 @@ class ResourceWithProps(GenericResource):
'FooInt': properties.Schema(properties.Schema.INTEGER)}
class ResourceWithPropsRefPropOnDelete(ResourceWithProps):
def check_delete_complete(self, cookie):
return self.properties['FooInt'] is not None
class ResourceWithPropsAndAttrs(ResourceWithProps):
attributes_schema = {'Bar': attributes.Schema('Something.')}

View File

@ -1695,13 +1695,15 @@ class StackUpdateTest(common.HeatTestCase):
tmpl_update = {
'heat_template_version': '2013-05-23',
'parameters': {'aparam': {'type': 'number', 'default': 1}},
'resources': {
'Ares': {'type': 'GenericResourceType'},
'Bres': {'type': 'GenericResourceType'},
'Cres': {
'type': 'ResourceWithPropsType',
'type': 'ResourceWithPropsRefPropOnDelete',
'properties': {
'Foo': {'get_resource': 'Bres'},
'FooInt': {'get_param': 'aparam'},
}
}
}