mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 05:55:59 -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:
@@ -606,6 +606,12 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin):
|
|||||||
evars.update(extra_vars)
|
evars.update(extra_vars)
|
||||||
self.update_fields(extra_vars=json.dumps(evars))
|
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):
|
def display_artifacts(self):
|
||||||
'''
|
'''
|
||||||
Hides artifacts if they are marked as no_log type artifacts.
|
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.conf import settings
|
||||||
from django.db import transaction, connection
|
from django.db import transaction, connection
|
||||||
from django.db.utils import DatabaseError
|
from django.db.utils import DatabaseError
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.models import * # noqa
|
from awx.main.models import * # noqa
|
||||||
@@ -123,7 +124,8 @@ class TaskManager():
|
|||||||
can_start = job.signal_start(**kv)
|
can_start = job.signal_start(**kv)
|
||||||
if not can_start:
|
if not can_start:
|
||||||
job.status = 'failed'
|
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'])
|
job.save(update_fields=['status', 'job_explanation'])
|
||||||
connection.on_commit(lambda: job.websocket_emit_status('failed'))
|
connection.on_commit(lambda: job.websocket_emit_status('failed'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user