summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-31 22:18:59 +0000
committerGerrit Code Review <review@openstack.org>2015-03-31 22:18:59 +0000
commit7541cacfdd6289988925c5683451f497709e9c67 (patch)
treedd35f32a5dd09644375176056be1a00b01c62459
parent051cb7a015f5129bdb405d25b266406a83cd0b27 (diff)
parent29365bda1cab48aad7b98907af521130321e526a (diff)
downloadheat-7541cacfdd6289988925c5683451f497709e9c67.tar.gz
Merge "Set state to failed if we get a base exception"
-rwxr-xr-xheat/engine/stack.py11
-rw-r--r--heat/tests/test_stack.py29
2 files changed, 37 insertions, 3 deletions
diff --git a/heat/engine/stack.py b/heat/engine/stack.py
index 466f0968c..7410c41f1 100755
--- a/heat/engine/stack.py
+++ b/heat/engine/stack.py
@@ -733,12 +733,17 @@ class Stack(collections.Mapping):
try:
yield action_task()
- except (exception.ResourceFailure, scheduler.ExceptionGroup) as ex:
- stack_status = self.FAILED
- reason = 'Resource %s failed: %s' % (action, six.text_type(ex))
except scheduler.Timeout:
stack_status = self.FAILED
reason = '%s timed out' % action.title()
+ except Exception as ex:
+ # We use a catch-all here to ensure any raised exceptions
+ # make the stack fail. This is necessary for when
+ # aggregate_exceptions is false, as in that case we don't get
+ # ExceptionGroup, but the raw exception.
+ # see scheduler.py line 395-399
+ stack_status = self.FAILED
+ reason = 'Resource %s failed: %s' % (action, six.text_type(ex))
self.state_set(action, stack_status, reason)
diff --git a/heat/tests/test_stack.py b/heat/tests/test_stack.py
index 65d3116a3..4795e0f2a 100644
--- a/heat/tests/test_stack.py
+++ b/heat/tests/test_stack.py
@@ -936,6 +936,35 @@ class StackTest(common.HeatTestCase):
self.m.VerifyAll()
+ def test_create_bad_attribute(self):
+ tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
+ 'Resources': {
+ 'AResource': {'Type': 'GenericResourceType'},
+ 'BResource': {'Type': 'ResourceWithPropsType',
+ 'Properties': {
+ 'Foo': {'Fn::GetAtt': ['AResource',
+ 'Foo']}}}}}
+ self.stack = stack.Stack(self.ctx, 'bad_attr_test_stack',
+ template.Template(tmpl),
+ disable_rollback=True)
+
+ self.m.StubOutWithMock(generic_rsrc.ResourceWithProps,
+ '_update_stored_properties')
+
+ generic_rsrc.ResourceWithProps._update_stored_properties().AndRaise(
+ exception.InvalidTemplateAttribute(resource='a', key='foo'))
+
+ self.m.ReplayAll()
+
+ self.stack.store()
+ self.stack.create()
+
+ self.assertEqual((stack.Stack.CREATE, stack.Stack.FAILED),
+ self.stack.state)
+ self.assertEqual('Resource CREATE failed: The Referenced Attribute '
+ '(a foo) is incorrect.', self.stack.status_reason)
+ self.m.VerifyAll()
+
def test_stack_create_timeout(self):
self.m.StubOutWithMock(scheduler.DependencyTaskGroup, '__call__')
self.m.StubOutWithMock(scheduler, 'wallclock')