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,
|
||||
objects.action.State.SUCCEEDED)
|
||||
else:
|
||||
return self.engine.notify(self._db_action,
|
||||
objects.action.State.FAILED)
|
||||
self.engine.notify(self._db_action,
|
||||
objects.action.State.FAILED)
|
||||
raise exception.ActionExecutionFailure(
|
||||
action_id=self._db_action.uuid)
|
||||
|
||||
def do_post_execute(self):
|
||||
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.")
|
||||
|
||||
|
||||
class ActionExecutionFailure(WatcherException):
|
||||
msg_fmt = _("The action %(action_id)s execution failed.")
|
||||
|
||||
|
||||
# Model
|
||||
|
||||
class ComputeResourceNotFound(WatcherException):
|
||||
|
||||
@@ -51,7 +51,7 @@ class FakeAction(abase.BaseAction):
|
||||
pass
|
||||
|
||||
def execute(self):
|
||||
raise ExpectedException()
|
||||
return False
|
||||
|
||||
def get_description(self):
|
||||
return "fake action, just for test"
|
||||
@@ -311,7 +311,8 @@ class TestDefaultWorkFlowEngine(base.DbTestCase):
|
||||
exc = self.assertRaises(exception.WorkflowExecutionException,
|
||||
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)
|
||||
|
||||
@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.common import clients
|
||||
from watcher.common import exception
|
||||
from watcher.common import nova_helper
|
||||
from watcher import objects
|
||||
from watcher.tests.db import base
|
||||
@@ -79,7 +80,9 @@ class TestTaskFlowActionContainer(base.DbTestCase):
|
||||
action_container = tflow.TaskFlowActionContainer(
|
||||
db_action=action,
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user