adjust recursion error text

This commit is contained in:
AlanCoding
2018-11-05 14:48:34 -05:00
committed by Marliana Lara
parent a3d5705cea
commit 0783d86c6c
3 changed files with 8 additions and 7 deletions

View File

@@ -527,7 +527,7 @@ class WorkflowJob(UnifiedJob, WorkflowJobOptions, SurveyJobMixin, JobNotificatio
'this is not normal and suggests task manager degeneracy.')
break
wj_ids.add(wj.pk)
ancestors.append(wj.workflow_job_template_id)
ancestors.append(wj.workflow_job_template)
wj = wj.get_workflow_job()
return ancestors

View File

@@ -124,17 +124,18 @@ class TaskManager():
can_start = True
if isinstance(spawn_node.unified_job_template, WorkflowJobTemplate):
workflow_ancestors = job.get_ancestor_workflows()
if spawn_node.unified_job_template.id in set(workflow_ancestors):
if spawn_node.unified_job_template in set(workflow_ancestors):
can_start = False
logger.info('Refusing to start recursive workflow-in-workflow id={}, wfjt={}, ancestors={}'.format(
job.id, spawn_node.unified_job_template.id, workflow_ancestors))
job.id, spawn_node.unified_job_template.pk, [wa.pk for wa in workflow_ancestors]))
display_list = [spawn_node.unified_job_template] + workflow_ancestors
job.job_explanation = _(
"Workflow Job spawned from workflow could not start because it "
"would result in recursion (template spawn order {})"
).format([spawn_node.unified_job_template.id] + workflow_ancestors)
"would result in recursion (spawn order, most recent first: {})"
).format(six.text_type(', ').join([six.text_type('<{}>').format(tmp) for tmp in display_list]))
else:
logger.debug('Starting workflow-in-workflow id={}, wfjt={}, ancestors={}'.format(
job.id, spawn_node.unified_job_template.id, workflow_ancestors))
job.id, spawn_node.unified_job_template.pk, [wa.pk for wa in workflow_ancestors]))
if not job._resources_sufficient_for_launch():
can_start = False
job.job_explanation = _("Job spawned from workflow could not start because it "

View File

@@ -249,7 +249,7 @@ def test_workflow_ancestors(organization):
job=parent_job
)
# ancestors method gives a list of WFJT ids
assert child_job.get_ancestor_workflows() == [parent.pk, grandparent.pk]
assert child_job.get_ancestor_workflows() == [parent, grandparent]
@pytest.mark.django_db