diff --git a/app/models/task.py b/app/models/task.py index 365747ff..d80f4faf 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -301,7 +301,6 @@ class Task(models.Model): self.processing_node.save() logger.info("Automatically assigned processing node {} to {}".format(self.processing_node, self)) - self.status = None self.save() # Processing node assigned, but is offline and no errors @@ -313,7 +312,9 @@ class Task(models.Model): logger.info("Processing node {} went offline, reassigning {}...".format(self.processing_node, self)) self.uuid = '' self.processing_node = None + self.status = None self.save() + elif self.status == status_codes.RUNNING: # Task was running and processing node went offline # It could have crashed due to low memory diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index f28ef8d5..4b90f476 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -580,14 +580,15 @@ class TestApiTask(BootTransactionTestCase): # Processing node is now cleared and a new one will be assigned on the next tick task.refresh_from_db() self.assertTrue(task.processing_node is None) + self.assertTrue(task.status is None) worker.tasks.process_pending_tasks() task.refresh_from_db() self.assertTrue(task.processing_node.id == another_pnode.id) - self.assertTrue(task.status == None) # Set task to queued, bring node offline + task.last_error = None task.status = status_codes.RUNNING task.save() another_pnode.last_refreshed = timezone.now() - timedelta(minutes=OFFLINE_MINUTES)