From 5169fe348494b6333b79ffbc603ee344029af7a4 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 1 Oct 2018 16:35:50 -0400 Subject: [PATCH] safeguard against infinite loop if jobs have cycles --- awx/main/models/workflow.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 0753ae4992..2b23b0adbc 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -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)