From 4f0cd9d16094c9b5c22448fc7cbed7ba2d5fb38b Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 5 Sep 2014 15:13:16 -0400 Subject: [PATCH] Make sure cancel can cancel jobs that are in the pending or waiting state also --- awx/main/models/unified_jobs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index 4da5ada343..d7786f0af8 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -639,7 +639,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique @property 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): # 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 not self.cancel_flag: 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") if settings.BROKER_URL.startswith('amqp://'): self._force_cancel()