mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
parent
b533a9eb7b
commit
bdfac35f3f
@ -654,6 +654,15 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin):
|
|||||||
def get_notification_friendly_name(self):
|
def get_notification_friendly_name(self):
|
||||||
return "Job"
|
return "Job"
|
||||||
|
|
||||||
|
'''
|
||||||
|
Canceling a job also cancels the implicit project update with launch_type
|
||||||
|
run.
|
||||||
|
'''
|
||||||
|
def cancel(self):
|
||||||
|
res = super(Job, self).cancel()
|
||||||
|
if self.project_update:
|
||||||
|
self.project_update.cancel()
|
||||||
|
return res
|
||||||
|
|
||||||
class JobHostSummary(CreatedModifiedModel):
|
class JobHostSummary(CreatedModifiedModel):
|
||||||
'''
|
'''
|
||||||
|
@ -708,6 +708,11 @@ class BaseTask(Task):
|
|||||||
stdout_handle.close()
|
stdout_handle.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
instance = self.update_model(pk)
|
||||||
|
if instance.cancel_flag:
|
||||||
|
status = 'canceled'
|
||||||
|
|
||||||
instance = self.update_model(pk, status=status, result_traceback=tb,
|
instance = self.update_model(pk, status=status, result_traceback=tb,
|
||||||
output_replacements=output_replacements,
|
output_replacements=output_replacements,
|
||||||
**extra_update_fields)
|
**extra_update_fields)
|
||||||
@ -1044,17 +1049,18 @@ class RunJob(BaseTask):
|
|||||||
local_project_sync = job.project.create_project_update(launch_type="sync")
|
local_project_sync = job.project.create_project_update(launch_type="sync")
|
||||||
local_project_sync.job_type = 'run'
|
local_project_sync.job_type = 'run'
|
||||||
local_project_sync.save()
|
local_project_sync.save()
|
||||||
|
# save the associated project update before calling run() so that a
|
||||||
|
# cancel() call on the job can cancel the project update
|
||||||
|
job = self.update_model(job.pk, project_update=local_project_sync)
|
||||||
|
|
||||||
project_update_task = local_project_sync._get_task_class()
|
project_update_task = local_project_sync._get_task_class()
|
||||||
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 = self.update_model(job.pk, scm_revision=project.scm_revision)
|
||||||
job.project_update = local_project_sync
|
|
||||||
job.save()
|
|
||||||
except Exception:
|
except Exception:
|
||||||
job.status = 'failed'
|
job = self.update_model(job.pk, status='failed',
|
||||||
job.job_explanation = 'Previous Task Failed: {"job_type": "%s", "job_name": "%s", "job_id": "%s"}' % \
|
job_explanation='Previous Task Failed: {"job_type": "%s", "job_name": "%s", "job_id": "%s"}' % \
|
||||||
('project_update', local_project_sync.name, local_project_sync.id)
|
('project_update', local_project_sync.name, local_project_sync.id))
|
||||||
job.save()
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def post_run_hook(self, job, status, **kwargs):
|
def post_run_hook(self, job, status, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user