|
@@ -23,31 +23,17 @@ CONF = conf.CONF
|
|
|
CONF.register_opts(REPLICA_EXECUTION_API_OPTS)
|
|
CONF.register_opts(REPLICA_EXECUTION_API_OPTS)
|
|
|
|
|
|
|
|
|
|
|
|
|
-def _sort_tasks(tasks):
|
|
|
|
|
- non_error_only_tasks = [t for t in tasks if
|
|
|
|
|
- not t["depends_on"] and not t["on_error"]]
|
|
|
|
|
-
|
|
|
|
|
- def _add_non_error_tasks(task_id):
|
|
|
|
|
- for t in tasks:
|
|
|
|
|
- if (t["depends_on"] and task_id in t["depends_on"] and
|
|
|
|
|
- t not in non_error_only_tasks):
|
|
|
|
|
- non_error_only_tasks.append(t)
|
|
|
|
|
- _add_non_error_tasks(t["id"])
|
|
|
|
|
-
|
|
|
|
|
- for t in non_error_only_tasks:
|
|
|
|
|
- _add_non_error_tasks(t["id"])
|
|
|
|
|
-
|
|
|
|
|
- # Include error only tasks only if executed
|
|
|
|
|
- error_only_tasks = [t for t in tasks if t["status"] !=
|
|
|
|
|
- constants.TASK_STATUS_ON_ERROR_ONLY and
|
|
|
|
|
- t not in non_error_only_tasks]
|
|
|
|
|
-
|
|
|
|
|
- sorted_tasks = sorted(
|
|
|
|
|
- non_error_only_tasks, key=lambda t: t.get('index', 0))
|
|
|
|
|
- sorted_tasks.extend(sorted(
|
|
|
|
|
- error_only_tasks, key=lambda t: t.get('index', 0)))
|
|
|
|
|
-
|
|
|
|
|
- return sorted_tasks
|
|
|
|
|
|
|
+def _sort_tasks(tasks, filter_error_only_tasks=True):
|
|
|
|
|
+ """ Sorts the given list of dicts representing tasks.
|
|
|
|
|
+ Tasks are sorted primarily based on their index.
|
|
|
|
|
+ """
|
|
|
|
|
+ if filter_error_only_tasks:
|
|
|
|
|
+ tasks = [
|
|
|
|
|
+ t for t in tasks
|
|
|
|
|
+ if t['status'] != (
|
|
|
|
|
+ constants.TASK_STATUS_ON_ERROR_ONLY)]
|
|
|
|
|
+ return sorted(
|
|
|
|
|
+ tasks, key=lambda t: t.get('index', 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_replica_tasks_execution(req, execution, keys=None):
|
|
def format_replica_tasks_execution(req, execution, keys=None):
|