summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-02-29 04:45:02 +0000
committerGerrit Code Review <review@openstack.org>2016-02-29 04:45:02 +0000
commitec94602823e4f75ef9b787438b82d1370b3866c0 (patch)
tree340bebb29afd362da26a07dbbfa318a642cea64b
parentd20a75b2fc9971c3b5f37a508e58a965de9cf005 (diff)
parentec9404a6644224647c787ea7f991d518d75651ff (diff)
downloadheat-ec94602823e4f75ef9b787438b82d1370b3866c0.tar.gz
Merge "Ignore errors on old properties during update" into stable/liberty
-rw-r--r--heat/engine/resource.py20
-rw-r--r--heat_integrationtests/functional/test_template_resource.py87
2 files changed, 104 insertions, 3 deletions
diff --git a/heat/engine/resource.py b/heat/engine/resource.py
index c492e88a8..e81da4029 100644
--- a/heat/engine/resource.py
+++ b/heat/engine/resource.py
@@ -492,10 +492,24 @@ class Resource(object):
if psv.immutable():
immutable_set.add(psk)
+ def prop_changed(key):
+ try:
+ before = before_props.get(key)
+ except ValueError as exc:
+ # We shouldn't get here usually, but there is a known issue
+ # with template resources and new parameters in non-convergence
+ # stacks (see bug 1543685). The error should be harmless
+ # because we're on the before properties, which have presumably
+ # already been validated.
+ LOG.warning(_LW('Ignoring error in old property value '
+ '%(prop_name)s: %(msg)s'),
+ {'prop_name': key, 'msg': six.text_type(exc)})
+ return True
+
+ return before != after_props.get(key)
+
# Create a set of keys which differ (or are missing/added)
- changed_properties_set = set(k for k in after_props
- if before_props.get(k) !=
- after_props.get(k))
+ changed_properties_set = set(k for k in after_props if prop_changed(k))
# Create a list of updated properties offending property immutability
update_replace_forbidden = [k for k in changed_properties_set
diff --git a/heat_integrationtests/functional/test_template_resource.py b/heat_integrationtests/functional/test_template_resource.py
index 1ec05d993..9ae7a2dcb 100644
--- a/heat_integrationtests/functional/test_template_resource.py
+++ b/heat_integrationtests/functional/test_template_resource.py
@@ -803,3 +803,90 @@ resources:
exp = ('ERROR: Attribute here-it-is for facade '
'OS::Thingy missing in provider')
self.assertEqual(exp, six.text_type(exc))
+
+
+class TemplateResourceNewParamTest(functional_base.FunctionalTestsBase):
+
+ main_template = '''
+heat_template_version: 2013-05-23
+resources:
+ my_resource:
+ type: resource.yaml
+ properties:
+ value1: foo
+'''
+ nested_templ = '''
+heat_template_version: 2013-05-23
+parameters:
+ value1:
+ type: string
+resources:
+ test:
+ type: OS::Heat::TestResource
+ properties:
+ value: {get_param: value1}
+'''
+ main_template_update = '''
+heat_template_version: 2013-05-23
+resources:
+ my_resource:
+ type: resource.yaml
+ properties:
+ value1: foo
+ value2: foo
+'''
+ nested_templ_update_fail = '''
+heat_template_version: 2013-05-23
+parameters:
+ value1:
+ type: string
+ value2:
+ type: string
+resources:
+ test:
+ type: OS::Heat::TestResource
+ properties:
+ fail: True
+ value:
+ str_replace:
+ template: VAL1-VAL2
+ params:
+ VAL1: {get_param: value1}
+ VAL2: {get_param: value2}
+'''
+ nested_templ_update = '''
+heat_template_version: 2013-05-23
+parameters:
+ value1:
+ type: string
+ value2:
+ type: string
+resources:
+ test:
+ type: OS::Heat::TestResource
+ properties:
+ value:
+ str_replace:
+ template: VAL1-VAL2
+ params:
+ VAL1: {get_param: value1}
+ VAL2: {get_param: value2}
+'''
+
+ def test_update(self):
+ stack_identifier = self.stack_create(
+ template=self.main_template,
+ files={'resource.yaml': self.nested_templ})
+
+ # Make the update fails with the new parameter inserted.
+ self.update_stack(
+ stack_identifier,
+ self.main_template_update,
+ files={'resource.yaml': self.nested_templ_update_fail},
+ expected_status='UPDATE_FAILED')
+
+ # Fix the update, it should succeed now.
+ self.update_stack(
+ stack_identifier,
+ self.main_template_update,
+ files={'resource.yaml': self.nested_templ_update})