mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Merge pull request #4732 from AlanCoding/null_job_fd
Graceful handling of null project and inventory in workflow
This commit is contained in:
commit
c5ae2ddb5d
@ -606,6 +606,12 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin):
|
||||
evars.update(extra_vars)
|
||||
self.update_fields(extra_vars=json.dumps(evars))
|
||||
|
||||
def signal_start(self, **kwargs):
|
||||
# Block cases that would cause the task manager to error
|
||||
if self.inventory_id is None or self.project_id is None:
|
||||
return False
|
||||
return super(Job, self).signal_start(**kwargs)
|
||||
|
||||
def display_artifacts(self):
|
||||
'''
|
||||
Hides artifacts if they are marked as no_log type artifacts.
|
||||
|
||||
@ -10,6 +10,7 @@ from sets import Set
|
||||
from django.conf import settings
|
||||
from django.db import transaction, connection
|
||||
from django.db.utils import DatabaseError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
# AWX
|
||||
from awx.main.models import * # noqa
|
||||
@ -123,7 +124,8 @@ class TaskManager():
|
||||
can_start = job.signal_start(**kv)
|
||||
if not can_start:
|
||||
job.status = 'failed'
|
||||
job.job_explanation = "Workflow job could not start because it was not in the right state or required manual credentials"
|
||||
job.job_explanation = _("Job spawned from workflow could not start because it "
|
||||
"was not in the right state or required manual credentials")
|
||||
job.save(update_fields=['status', 'job_explanation'])
|
||||
connection.on_commit(lambda: job.websocket_emit_status('failed'))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user