]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : Only create periodic task on CREATE_COMPLETE
authorSteven Hardy <shardy@redhat.com>
Fri, 15 Feb 2013 18:31:13 +0000 (18:31 +0000)
committerSteven Hardy <shardy@redhat.com>
Tue, 19 Feb 2013 10:59:48 +0000 (10:59 +0000)
Only create the stack periodic watcher task if the stack create
completed successfully, since we don't want a watcher task if
the stack ended up rolling back (or just in CREATE_FAILED state)

Change-Id: I5592fa106f740eb2e1dcf40e98a2656627715b6f

heat/engine/service.py

index 66009e91265ea867f9b716df875501736bb2492a..dbad59dbc9709d387b59aade43f8854156860527 100644 (file)
@@ -193,6 +193,16 @@ class EngineService(service.Service):
         """
         logger.info('template is %s' % template)
 
+        def _stack_create(stack):
+            # Create the stack, and create the periodic task if successful
+            stack.create()
+            if stack.state == stack.CREATE_COMPLETE:
+                # Schedule a periodic watcher task for this stack
+                self._timer_in_thread(stack.id, self._periodic_watcher_task,
+                                      sid=stack.id)
+            else:
+                logger.warning("Stack create failed, state %s" % stack.state)
+
         if db_api.stack_get_by_name(context, stack_name):
             raise exception.StackExists(stack_name=stack_name)
 
@@ -211,11 +221,7 @@ class EngineService(service.Service):
 
         stack_id = stack.store()
 
-        self._start_in_thread(stack_id, stack.create)
-
-        # Schedule a periodic watcher task for this stack
-        self._timer_in_thread(stack_id, self._periodic_watcher_task,
-                              sid=stack_id)
+        self._start_in_thread(stack_id, _stack_create, stack)
 
         return dict(stack.identifier())