mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Store the job's project refresh if it happened
* Create a field on the job to track this * Add a summarizeable model to the summarizable fk fields so we can pull that in where needed
This commit is contained in:
@@ -75,10 +75,11 @@ SUMMARIZABLE_FK_FIELDS = {
|
|||||||
'groups_with_active_failures',
|
'groups_with_active_failures',
|
||||||
'has_inventory_sources'),
|
'has_inventory_sources'),
|
||||||
'project': DEFAULT_SUMMARY_FIELDS + ('status',),
|
'project': DEFAULT_SUMMARY_FIELDS + ('status',),
|
||||||
|
'project_update': DEFAULT_SUMMARY_FIELDS + ('status', 'failed',),
|
||||||
'credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud'),
|
'credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud'),
|
||||||
'cloud_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud'),
|
'cloud_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud'),
|
||||||
'network_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'net'),
|
'network_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'net'),
|
||||||
'job': DEFAULT_SUMMARY_FIELDS + ('status', 'failed',),
|
'job': DEFAULT_SUMMARY_FIELDS + ('status', 'failed', 'project_update',),
|
||||||
'job_template': DEFAULT_SUMMARY_FIELDS,
|
'job_template': DEFAULT_SUMMARY_FIELDS,
|
||||||
'schedule': DEFAULT_SUMMARY_FIELDS + ('next_run',),
|
'schedule': DEFAULT_SUMMARY_FIELDS + ('next_run',),
|
||||||
'unified_job_template': DEFAULT_SUMMARY_FIELDS + ('unified_job_type',),
|
'unified_job_template': DEFAULT_SUMMARY_FIELDS + ('unified_job_type',),
|
||||||
@@ -1963,6 +1964,8 @@ class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer):
|
|||||||
res['start'] = reverse('api:job_start', args=(obj.pk,))
|
res['start'] = reverse('api:job_start', args=(obj.pk,))
|
||||||
if obj.can_cancel or True:
|
if obj.can_cancel or True:
|
||||||
res['cancel'] = reverse('api:job_cancel', args=(obj.pk,))
|
res['cancel'] = reverse('api:job_cancel', args=(obj.pk,))
|
||||||
|
if obj.project_update:
|
||||||
|
res['project_update'] = reverse('api:project_update_detail', args=(obj.project_update.pk,))
|
||||||
res['relaunch'] = reverse('api:job_relaunch', args=(obj.pk,))
|
res['relaunch'] = reverse('api:job_relaunch', args=(obj.pk,))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
20
awx/main/migrations/0051_v310_job_project_update.py
Normal file
20
awx/main/migrations/0051_v310_job_project_update.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('main', '0050_v310_JSONField_changes'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='job',
|
||||||
|
name='project_update',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, default=None, blank=True, to='main.ProjectUpdate', help_text='The SCM Refresh task used to make sure the playbooks were available for the job run', null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -432,6 +432,15 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin):
|
|||||||
verbose_name=_('SCM Revision'),
|
verbose_name=_('SCM Revision'),
|
||||||
help_text=_('The SCM Revision from the Project used for this job, if available'),
|
help_text=_('The SCM Revision from the Project used for this job, if available'),
|
||||||
)
|
)
|
||||||
|
project_update = models.ForeignKey(
|
||||||
|
'ProjectUpdate',
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
default=None,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
help_text=_('The SCM Refresh task used to make sure the playbooks were available for the job run'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -1025,6 +1025,7 @@ class RunJob(BaseTask):
|
|||||||
try:
|
try:
|
||||||
project_update_task().run(local_project_sync.id)
|
project_update_task().run(local_project_sync.id)
|
||||||
job.scm_revision = job.project.scm_revision
|
job.scm_revision = job.project.scm_revision
|
||||||
|
job.project_update = local_project_sync
|
||||||
job.save()
|
job.save()
|
||||||
except Exception:
|
except Exception:
|
||||||
job.status = 'failed'
|
job.status = 'failed'
|
||||||
|
|||||||
Reference in New Issue
Block a user