]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Mark resources as failed when creation aborted
authorZane Bitter <zbitter@redhat.com>
Tue, 23 Apr 2013 11:36:47 +0000 (13:36 +0200)
committerZane Bitter <zbitter@redhat.com>
Tue, 23 Apr 2013 11:36:51 +0000 (13:36 +0200)
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

index 3a60c0a31a4fe2839cb252d6b5bfc64b6f518227..bef28a85f0e4d7c0139939a5032d9d3fd4676c2d 100644 (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)