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
This commit is contained in:
Zane Bitter 2013-04-23 13:36:47 +02:00
parent 9e90af14cf
commit 2570ef9ccd
1 changed files with 14 additions and 1 deletions

View File

@ -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)