mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Revert "optimize mark dnr nodes algorithm"
This reverts commit 6372c52772e26f64f3b4fd227ffb5e401d3688e1.
This commit is contained in:
parent
3c510e6344
commit
cfa098479e
@ -1,11 +1,8 @@
|
||||
|
||||
|
||||
class SimpleDAG(object):
|
||||
''' A simple implementation of a directed acyclic graph '''
|
||||
|
||||
def __init__(self):
|
||||
# Depth
|
||||
self.depth = [set([])]
|
||||
self.nodes = []
|
||||
self.root_nodes = set([])
|
||||
|
||||
@ -102,8 +99,6 @@ class SimpleDAG(object):
|
||||
gv_file.close()
|
||||
|
||||
def add_node(self, obj, metadata=None):
|
||||
if not metadata:
|
||||
metadata = dict()
|
||||
if self.find_ord(obj) is None:
|
||||
'''
|
||||
Assume node is a root node until a child is added
|
||||
@ -114,11 +109,6 @@ class SimpleDAG(object):
|
||||
entry = dict(node_object=obj, metadata=metadata)
|
||||
self.nodes.append(entry)
|
||||
|
||||
# Depth
|
||||
metadata['depth'] = 0
|
||||
self.depth[0].add(node_index)
|
||||
return node_index
|
||||
|
||||
def add_edge(self, from_obj, to_obj, label):
|
||||
from_obj_ord = self.find_ord(from_obj)
|
||||
to_obj_ord = self.find_ord(to_obj)
|
||||
@ -143,19 +133,6 @@ class SimpleDAG(object):
|
||||
self.node_from_edges_by_label[label][from_obj_ord].append(to_obj_ord)
|
||||
self.node_to_edges_by_label[label][to_obj_ord].append(from_obj_ord)
|
||||
|
||||
# Depth
|
||||
parent_depth = self.nodes[from_obj_ord]['metadata']['depth']
|
||||
current_depth = self.nodes[to_obj_ord]['metadata']['depth']
|
||||
if parent_depth >= current_depth:
|
||||
if len(self.depth) <= parent_depth + 1:
|
||||
self.depth.append(set([]))
|
||||
|
||||
self.nodes[to_obj_ord]['metadata']['depth'] = parent_depth + 1
|
||||
|
||||
self.depth[current_depth].remove(to_obj_ord)
|
||||
self.depth[parent_depth + 1].add(to_obj_ord)
|
||||
|
||||
|
||||
def find_ord(self, obj):
|
||||
return self.node_obj_to_node_index.get(obj, None)
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
# Python
|
||||
import copy
|
||||
from awx.main.models import (
|
||||
WorkflowJobTemplateNode,
|
||||
WorkflowJobNode,
|
||||
@ -200,12 +201,13 @@ class WorkflowDAG(SimpleDAG):
|
||||
|
||||
def mark_dnr_nodes(self):
|
||||
root_nodes = self.get_root_nodes()
|
||||
nodes = copy.copy(root_nodes)
|
||||
nodes_marked_do_not_run = []
|
||||
|
||||
for node_indexes in self.depth:
|
||||
for node_index in node_indexes:
|
||||
node = self.nodes[node_index]
|
||||
obj = node['node_object']
|
||||
for index, node in enumerate(nodes):
|
||||
obj = node['node_object']
|
||||
|
||||
if obj.do_not_run is False and not obj.job:
|
||||
parent_nodes = [p['node_object'] for p in self.get_dependents(obj)]
|
||||
if self._are_all_nodes_dnr_decided(parent_nodes):
|
||||
if obj.unified_job_template is None:
|
||||
@ -214,4 +216,8 @@ class WorkflowDAG(SimpleDAG):
|
||||
elif node not in root_nodes and self._should_mark_node_dnr(node, parent_nodes):
|
||||
obj.do_not_run = True
|
||||
nodes_marked_do_not_run.append(node)
|
||||
|
||||
nodes.extend(self.get_dependencies(obj, 'success_nodes') +
|
||||
self.get_dependencies(obj, 'failure_nodes') +
|
||||
self.get_dependencies(obj, 'always_nodes'))
|
||||
return [n['node_object'] for n in nodes_marked_do_not_run]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user