mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-17 13:31:47 -05:00
Disallow creating callback jobs for the same host under the same job
template while another one is pending/waiting. Update unit tests to check for this scenario
This commit is contained in:
@@ -1693,6 +1693,12 @@ class JobTemplateCallback(GenericAPIView):
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
limit = ':&'.join(filter(None, [job_template.limit, host.name]))
|
||||
|
||||
# NOTE: We limit this to one job waiting due to this: https://trello.com/c/yK36dGWp
|
||||
if Job.objects.filter(status__in=['pending', 'waiting', 'running'], job_template=job_template,
|
||||
limit=limit).count() > 0:
|
||||
data = dict(msg='Host callback job already pending')
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# Everything is fine; actually create the job.
|
||||
with transaction.atomic():
|
||||
job = job_template.create_job(limit=limit, launch_type='callback')
|
||||
|
||||
Reference in New Issue
Block a user