mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
fix a few bugs for scheduled jobs that run without inventories
see: https://github.com/ansible/ansible-tower/issues/7865 see: https://github.com/ansible/ansible-tower/issues/7866
This commit is contained in:
parent
b0a755d7b5
commit
e642af82cc
@ -1119,6 +1119,8 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
def can_schedule(self):
|
||||
if getattr(self, 'passwords_needed_to_start', None):
|
||||
return False
|
||||
if getattr(self, 'inventory', None) is None:
|
||||
return False
|
||||
JobLaunchConfig = self._meta.get_field('launch_config').related_model
|
||||
try:
|
||||
self.launch_config
|
||||
|
||||
@ -1178,6 +1178,10 @@ class RunJob(BaseTask):
|
||||
return getattr(settings, 'AWX_PROOT_ENABLED', False)
|
||||
|
||||
def pre_run_hook(self, job, **kwargs):
|
||||
if job.inventory is None:
|
||||
error = _('Job could not start because it does not have a valid inventory.')
|
||||
self.update_model(job.pk, status='failed', job_explanation=error)
|
||||
raise RuntimeError(error)
|
||||
if job.project and job.project.scm_type:
|
||||
job_request_id = '' if self.request.id is None else self.request.id
|
||||
pu_ig = job.instance_group
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user