Merge "Fix action plan state change when action failed"
This commit is contained in:
@@ -127,8 +127,10 @@ class TaskFlowActionContainer(base.BaseTaskFlowActionContainer):
|
|||||||
return self.engine.notify(self._db_action,
|
return self.engine.notify(self._db_action,
|
||||||
objects.action.State.SUCCEEDED)
|
objects.action.State.SUCCEEDED)
|
||||||
else:
|
else:
|
||||||
return self.engine.notify(self._db_action,
|
self.engine.notify(self._db_action,
|
||||||
objects.action.State.FAILED)
|
objects.action.State.FAILED)
|
||||||
|
raise exception.ActionExecutionFailure(
|
||||||
|
action_id=self._db_action.uuid)
|
||||||
|
|
||||||
def do_post_execute(self):
|
def do_post_execute(self):
|
||||||
LOG.debug("Post-condition action: %s", self.name)
|
LOG.debug("Post-condition action: %s", self.name)
|
||||||
|
|||||||
@@ -435,6 +435,10 @@ class ActionDescriptionNotFound(ResourceNotFound):
|
|||||||
msg_fmt = _("The action description %(action_id)s cannot be found.")
|
msg_fmt = _("The action description %(action_id)s cannot be found.")
|
||||||
|
|
||||||
|
|
||||||
|
class ActionExecutionFailure(WatcherException):
|
||||||
|
msg_fmt = _("The action %(action_id)s execution failed.")
|
||||||
|
|
||||||
|
|
||||||
# Model
|
# Model
|
||||||
|
|
||||||
class ComputeResourceNotFound(WatcherException):
|
class ComputeResourceNotFound(WatcherException):
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class FakeAction(abase.BaseAction):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
raise ExpectedException()
|
return False
|
||||||
|
|
||||||
def get_description(self):
|
def get_description(self):
|
||||||
return "fake action, just for test"
|
return "fake action, just for test"
|
||||||
@@ -311,7 +311,8 @@ class TestDefaultWorkFlowEngine(base.DbTestCase):
|
|||||||
exc = self.assertRaises(exception.WorkflowExecutionException,
|
exc = self.assertRaises(exception.WorkflowExecutionException,
|
||||||
self.engine.execute, actions)
|
self.engine.execute, actions)
|
||||||
|
|
||||||
self.assertIsInstance(exc.kwargs['error'], ExpectedException)
|
self.assertIsInstance(exc.kwargs['error'],
|
||||||
|
exception.ActionExecutionFailure)
|
||||||
self.check_action_state(actions[0], objects.action.State.FAILED)
|
self.check_action_state(actions[0], objects.action.State.FAILED)
|
||||||
|
|
||||||
@mock.patch.object(objects.ActionPlan, "get_by_uuid")
|
@mock.patch.object(objects.ActionPlan, "get_by_uuid")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import mock
|
|||||||
|
|
||||||
from watcher.applier.workflow_engine import default as tflow
|
from watcher.applier.workflow_engine import default as tflow
|
||||||
from watcher.common import clients
|
from watcher.common import clients
|
||||||
|
from watcher.common import exception
|
||||||
from watcher.common import nova_helper
|
from watcher.common import nova_helper
|
||||||
from watcher import objects
|
from watcher import objects
|
||||||
from watcher.tests.db import base
|
from watcher.tests.db import base
|
||||||
@@ -79,7 +80,9 @@ class TestTaskFlowActionContainer(base.DbTestCase):
|
|||||||
action_container = tflow.TaskFlowActionContainer(
|
action_container = tflow.TaskFlowActionContainer(
|
||||||
db_action=action,
|
db_action=action,
|
||||||
engine=self.engine)
|
engine=self.engine)
|
||||||
action_container.execute()
|
|
||||||
|
self.assertRaises(exception.ActionExecutionFailure,
|
||||||
|
action_container.execute, action_id=action.uuid)
|
||||||
|
|
||||||
self.assertTrue(action.state, objects.action.State.FAILED)
|
self.assertTrue(action.state, objects.action.State.FAILED)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user