diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index 8e234de943..10416df976 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -102,7 +102,7 @@ class UnifiedJobTemplate(PolymorphicModel, CommonModelNameNotUnique): # max_length=32, # choices=[], #) - next_job_run = models.DateTimeField( # FIXME: Calculate from schedules. + next_job_run = models.DateTimeField( null=True, default=None, editable=False, diff --git a/awx/main/tasks.py b/awx/main/tasks.py index d23194aa8e..8b1d43d4e6 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -79,7 +79,11 @@ def tower_periodic_scheduler(self): template = schedule.unified_job_template schedule.save() # To update next_run timestamp. new_unified_job = template.create_unified_job(launch_type='scheduled', schedule=schedule) - new_unified_job.signal_start() + can_start = new_unified_job.signal_start() + if not can_start: + new_unified_job.status = 'failed' + new_unified_job.job_explanation = "Scheduled job could not start because it was not in the right state or required manual credentials" + new_unified_job.save(update_fields=['job_status', 'job_explanation']) @task() def notify_task_runner(metadata_dict):