From 41e310655a16af37a38731f566311715d636a4b1 Mon Sep 17 00:00:00 2001 From: Tanya Tereshchenko Date: Mon, 17 May 2021 11:06:48 +0200 Subject: [PATCH] Skip running task if it is in any of the complete states closes #8766 https://pulp.plan.io/issues/8766 --- server/pulp/server/async/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/pulp/server/async/tasks.py b/server/pulp/server/async/tasks.py index 2f1a32d5b8..ff93dcfee5 100644 --- a/server/pulp/server/async/tasks.py +++ b/server/pulp/server/async/tasks.py @@ -450,13 +450,15 @@ def __call__(self, *args, **kwargs): This overrides PulpTask's __call__() method. We use this method for task state tracking of Pulp tasks. """ - # Check task status and skip running the task if task state is 'canceled'. + # Check task status and skip running the task if task state is in one of complete states. try: task_status = TaskStatus.objects.get(task_id=self.request.id) except DoesNotExist: task_status = None - if task_status and task_status['state'] == constants.CALL_CANCELED_STATE: - _logger.debug("Task cancel received for task-id : [%s]" % self.request.id) + if task_status and task_status['state'] in constants.CALL_COMPLETE_STATES: + _logger.debug( + "Task is in the %s state, task-id : [%s]" % (task_status['state'], self.request.id) + ) return # Update start_time and set the task state to 'running' for asynchronous tasks. # Skip updating status for eagerly executed tasks, since we don't want to track