mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Multi-ancestor detector added.
This commit is contained in:
parent
2792555510
commit
ad04015c9f
@ -71,7 +71,6 @@ from awx.api.metadata import RoleMetadata
|
||||
from awx.main.consumers import emit_channel_notification
|
||||
from awx.main.scheduler.dag_simple import SimpleDAG
|
||||
|
||||
|
||||
logger = logging.getLogger('awx.api.views')
|
||||
|
||||
def api_exception_handler(exc, context):
|
||||
@ -2677,7 +2676,10 @@ class WorkflowJobTemplateNodeChildrenBaseList(EnforceParentRelationshipMixin, Su
|
||||
graph.add_edge(parent, sub, self.relationship)
|
||||
|
||||
if graph.cycle_detected():
|
||||
return {"Error": "cycle detected!"}
|
||||
return {"Error": "Cycle detected!"}
|
||||
|
||||
if graph.multi_ancestor_detected():
|
||||
return {"Error": "Multiple ancestor detected!"}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@ -174,3 +174,16 @@ class SimpleDAG(object):
|
||||
|
||||
self._clean_meta()
|
||||
return False
|
||||
|
||||
def multi_ancestor_detected(self):
|
||||
for node in self.nodes:
|
||||
node['metadata'] = {"ancestor": None}
|
||||
for edge in self.edges:
|
||||
if self.nodes[edge[1]]['metadata']['ancestor'] is None:
|
||||
self.nodes[edge[1]]['metadata']['ancestor'] = self.nodes[edge[0]]
|
||||
else:
|
||||
self._clean_meta()
|
||||
return True
|
||||
|
||||
self._clean_meta()
|
||||
return False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user