From 800c43221e2ee98464c0621a3cbf17c5f0a93ec0 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 14 Aug 2013 15:31:01 +1200 Subject: [PATCH] Extract failure reason before deleting nova server If a nova server create fails, the server is deleted leaving no indication of the source of the failure. This change extracts the failure reason from the nova server fault attribute and includes that in the raised error. Change-Id: I7a4618d9e3fded3cde1c15d5322b52eaf63a68f5 --- heat/engine/resources/instance.py | 7 +++++-- heat/tests/test_instance.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 2b2376a0de..11d99de89f 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -323,10 +323,13 @@ class Instance(resource.Resource): volume_attach.start() return volume_attach.done() elif server.status == 'ERROR': + fault = server.fault or {} + message = fault.get('message', 'Unknown') + code = fault.get('code', 500) delete = scheduler.TaskRunner(self._delete_server, server) delete(wait_time=0.2) - exc = exception.Error("Build of server %s failed." % - server.name) + exc = exception.Error("Build of server %s failed: %s (%s)" % + (server.name, message, code)) raise exc else: exc = exception.Error('%s instance[%s] status[%s]' % diff --git a/heat/tests/test_instance.py b/heat/tests/test_instance.py index bb8f031268..8a07c346e2 100644 --- a/heat/tests/test_instance.py +++ b/heat/tests/test_instance.py @@ -225,6 +225,11 @@ class InstancesTest(HeatTestCase): instance = self._create_test_instance(return_server, 'test_instance_create') return_server.status = 'ERROR' + return_server.fault = { + 'message': 'NoValidHost', + 'code': 500, + 'created': '2013-08-14T03:12:10Z' + } self.m.StubOutWithMock(return_server, 'get') return_server.get() return_server.get().AndRaise(