mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Make sure cancel can cancel jobs that are in the pending or waiting
state also
This commit is contained in:
@@ -639,7 +639,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def can_cancel(self):
|
def can_cancel(self):
|
||||||
return bool(self.status in ('pending', 'waiting', 'running'))
|
return bool(self.status in ('new', 'pending', 'waiting', 'running'))
|
||||||
|
|
||||||
def _force_cancel(self):
|
def _force_cancel(self):
|
||||||
# Update the status to 'canceled' if we can detect that the job
|
# Update the status to 'canceled' if we can detect that the job
|
||||||
@@ -681,7 +681,8 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
|||||||
if self.can_cancel:
|
if self.can_cancel:
|
||||||
if not self.cancel_flag:
|
if not self.cancel_flag:
|
||||||
self.cancel_flag = True
|
self.cancel_flag = True
|
||||||
self.save(update_fields=['cancel_flag'])
|
self.status = 'canceled'
|
||||||
|
self.save(update_fields=['cancel_flag', 'status'])
|
||||||
self.socketio_emit_status("canceled")
|
self.socketio_emit_status("canceled")
|
||||||
if settings.BROKER_URL.startswith('amqp://'):
|
if settings.BROKER_URL.startswith('amqp://'):
|
||||||
self._force_cancel()
|
self._force_cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user