From 6f1cbac324b14e48f24c9687f08861f3ffc30ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Zahradn=C3=AD=C4=8Dek?= Date: Sat, 5 Jan 2019 21:44:43 +0100 Subject: [PATCH] Add SCHEDULE_MAX_JOBS implementation for WFJTs for #2975 --- awx/main/models/workflow.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 2c0beba698..c91a67e765 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -407,7 +407,11 @@ class WorkflowJobTemplate(UnifiedJobTemplate, WorkflowJobOptions, SurveyJobTempl @property def cache_timeout_blocked(self): - # TODO: don't allow running of job template if same workflow template running + if WorkflowJob.objects.filter(workflow_job_template=self, + status__in=['pending', 'waiting', 'running']).count() > getattr(settings, 'SCHEDULE_MAX_JOBS', 10): + logger.error("Workflow Job template %s could not be started because there are more than %s other jobs from that template waiting to run" % + (self.name, getattr(settings, 'SCHEDULE_MAX_JOBS', 10))) + return True return False @property