Cancel Action Plan
This patch adds feature to cancel action plan in watcher. A General flow from watcher-api to watcher-applier is implemented. action plan cancel can cancel any [ongoing, pending, recommended] action plan, it will update the action states also to "cancelled". For ongoing actions in action plan, actions needs to be aborted. Seperate patches will be added to support abort operation in each action. Notification part is addressed by a seperate blueprint. https://blueprints.launchpad.net/watcher/+spec/notifications-actionplan-cancel Change-Id: I895a5eaca5239d5657702c8d1875b9ece21682dc Partially-Implements: blueprint cancel-action-plan
This commit is contained in:
@@ -19,6 +19,7 @@ from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from taskflow import engines
|
||||
from taskflow import exceptions as tf_exception
|
||||
from taskflow.patterns import graph_flow as gf
|
||||
from taskflow import task as flow_task
|
||||
|
||||
@@ -90,6 +91,15 @@ class DefaultWorkFlowEngine(base.BaseWorkFlowEngine):
|
||||
|
||||
return flow
|
||||
|
||||
except exception.ActionPlanCancelled as e:
|
||||
raise
|
||||
|
||||
except tf_exception.WrappedFailure as e:
|
||||
if e.check("watcher.common.exception.ActionPlanCancelled"):
|
||||
raise exception.ActionPlanCancelled
|
||||
else:
|
||||
raise exception.WorkflowExecutionException(error=e)
|
||||
|
||||
except Exception as e:
|
||||
raise exception.WorkflowExecutionException(error=e)
|
||||
|
||||
@@ -121,7 +131,7 @@ class TaskFlowActionContainer(base.BaseTaskFlowActionContainer):
|
||||
LOG.debug("Post-condition action: %s", self.name)
|
||||
self.action.post_condition()
|
||||
|
||||
def revert(self, *args, **kwargs):
|
||||
def do_revert(self, *args, **kwargs):
|
||||
LOG.warning("Revert action: %s", self.name)
|
||||
try:
|
||||
# TODO(jed): do we need to update the states in case of failure?
|
||||
@@ -130,6 +140,15 @@ class TaskFlowActionContainer(base.BaseTaskFlowActionContainer):
|
||||
LOG.exception(e)
|
||||
LOG.critical("Oops! We need a disaster recover plan.")
|
||||
|
||||
def do_abort(self, *args, **kwargs):
|
||||
LOG.warning("Aborting action: %s", self.name)
|
||||
try:
|
||||
self.action.abort()
|
||||
self.engine.notify(self._db_action, objects.action.State.CANCELLED)
|
||||
except Exception as e:
|
||||
self.engine.notify(self._db_action, objects.action.State.FAILED)
|
||||
LOG.exception(e)
|
||||
|
||||
|
||||
class TaskFlowNop(flow_task.Task):
|
||||
"""This class is used in case of the workflow have only one Action.
|
||||
|
||||
Reference in New Issue
Block a user