From 2570ef9ccdb897692d8af91e75c880059b3a8df9 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 23 Apr 2013 13:36:47 +0200 Subject: [PATCH] Mark resources as failed when creation aborted Previously resources would be left in the CREATE_IN_PROGRESS state in the event of a timeout or the thread being cancelled (due to a delete being requested while the stack was still being created). We should instead put these resources into the CREATE_FAILED state when this occurs, thus creating an event with the reason. Change-Id: I05956aa9ef26941b79cef9dbf0cb6a347047d199 --- heat/engine/resource.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 3a60c0a3..bef28a85 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -20,6 +20,7 @@ from eventlet.support import greenlets as greenlet from heat.engine import event from heat.common import exception +from heat.openstack.common import excutils from heat.db import api as db_api from heat.common import identifier from heat.engine import timestamp @@ -321,12 +322,24 @@ class Resource(object): while not self.check_active(create_data): eventlet.sleep(1) except greenlet.GreenletExit: - raise + # Older versions of greenlet erroneously had GreenletExit inherit + # from Exception instead of BaseException + with excutils.save_and_reraise_exception(): + try: + self.state_set(self.CREATE_FAILED, 'Creation aborted') + except Exception: + logger.exception('Error marking resource as failed') except Exception as ex: logger.exception('create %s', str(self)) failure = exception.ResourceFailure(ex) self.state_set(self.CREATE_FAILED, str(failure)) raise failure + except: + with excutils.save_and_reraise_exception(): + try: + self.state_set(self.CREATE_FAILED, 'Creation aborted') + except Exception: + logger.exception('Error marking resource as failed') else: self.state_set(self.CREATE_COMPLETE) -- 2.45.2