mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 15:58:45 -03:30
Adjust the behavior of the cancel action
For pending and waiting jobs this should set the cancel status immediately. For running jobs it should just set the cancel flag and let the running job set the cancelled status itself during its cancelation procedure. This also prevents a race condition where the task manager will start dependent jobs before realizing the status is cancelled.
This commit is contained in:
@@ -783,8 +783,11 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
if self.can_cancel:
|
||||
if not self.cancel_flag:
|
||||
self.cancel_flag = True
|
||||
self.status = 'canceled'
|
||||
self.save(update_fields=['cancel_flag', 'status'])
|
||||
cancel_fields = ['cancel_flag']
|
||||
if self.status in ('pending', 'waiting'):
|
||||
self.status = 'canceled'
|
||||
cancel_fields.append('status')
|
||||
self.save(update_fields=cancel_fields)
|
||||
self.socketio_emit_status("canceled")
|
||||
if settings.BROKER_URL.startswith('amqp://'):
|
||||
self._force_cancel()
|
||||
|
||||
Reference in New Issue
Block a user