From 6d2a2ab71457603c8e89202a26bcaf7676ed3ccc Mon Sep 17 00:00:00 2001 From: Rebeccah Date: Wed, 22 Jan 2020 17:47:38 -0500 Subject: [PATCH] drastically improved performance by removing unnecessary iteration over children of parent nodes, additionally added an extra check that the node didn't already have a job so that it wasn't cycling over nodes that had already run when running through all_nodes --- awx/main/scheduler/dag_workflow.py | 48 ++++++++++++++---------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/awx/main/scheduler/dag_workflow.py b/awx/main/scheduler/dag_workflow.py index e7eaa5411e..4012be1421 100644 --- a/awx/main/scheduler/dag_workflow.py +++ b/awx/main/scheduler/dag_workflow.py @@ -210,36 +210,32 @@ class WorkflowDAG(SimpleDAG): for node in self.sort_nodes_topological(): obj = node['node_object'] - + parent_nodes = [p['node_object'] for p in self.get_parents(obj)] if obj.do_not_run is False and not obj.job and node not in root_nodes and not obj.all_parents_must_converge: - parent_nodes = [p['node_object'] for p in self.get_parents(obj)] if self._are_all_nodes_dnr_decided(parent_nodes): if self._should_mark_node_dnr(node, parent_nodes): obj.do_not_run = True nodes_marked_do_not_run.append(node) - if obj.do_not_run is False and obj.all_parents_must_converge: - if self._are_relevant_parents_finished(node): - # if the current node is a convergence node and all the - # parents are finished then check to see if all parents - # met the needed criteria to run the convergence child - # (i.e. parent must fail, parent must succeed) - parent_nodes = [p['node_object'] for p in self.get_parents(obj)] - if any(p.do_not_run for p in parent_nodes): - obj.do_not_run = True - nodes_marked_do_not_run.append(node) - else: - # import sdb - # sdb.set_trace() - for p in parent_nodes: - child_nodes = [] - if p.job.status == "successful": - child_nodes = [x for x in self.get_children(p, "success_nodes")] - elif p.job.status == "failed": - child_nodes = [x for x in self.get_children(p, "failure_nodes")] - child_nodes.extend(x for x in self.get_children(p, "always_nodes")) - if node not in child_nodes: - obj.do_not_run = True - nodes_marked_do_not_run.append(node) - break + if obj.do_not_run is False and obj.all_parents_must_converge and not obj.job: + if self._are_all_nodes_dnr_decided(parent_nodes): + if self._are_relevant_parents_finished(node): + # if the current node is a convergence node and all the + # parents are finished then check to see if all parents + # met the needed criteria to run the convergence child + # (i.e. parent must fail, parent must succeed) + if any(p.do_not_run for p in parent_nodes): + obj.do_not_run = True + nodes_marked_do_not_run.append(node) + else: + for p in parent_nodes: + if p.job.status == "successful": + status = "success_nodes" + elif p.job.status == "failed": + status = "failure_nodes" + if (p not in [node['node_object'] for node in self.get_parents(obj, status)] + and p not in [node['node_object'] for node in self.get_parents(obj, "always_nodes")]): + obj.do_not_run = True + nodes_marked_do_not_run.append(node) + break return [n['node_object'] for n in nodes_marked_do_not_run]