1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

safeguard against infinite loop if jobs have cycles

This commit is contained in:
AlanCoding 2018-10-01 16:35:50 -04:00 committed by Marliana Lara
parent 01d1470544
commit 5169fe3484
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE

View File

@ -516,8 +516,14 @@ class WorkflowJob(UnifiedJob, WorkflowJobOptions, SurveyJobMixin, JobNotificatio
def get_ancestor_workflows(self):
ancestors = []
wj = self
wj_ids = set([])
while True:
wj_ids.add(wj.id)
wj = wj.get_workflow_job()
if wj.id in wj_ids:
logger.critical('Cycles detected in the workflow jobs graph, '
'this is not normal and suggests task manager degeneracy.')
break
if (not wj) or (not wj.workflow_job_template_id):
break
ancestors.append(wj.workflow_job_template_id)