From cda52cf0ba183d97a54dcd6db9738851ef03a01f Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Thu, 13 Apr 2017 23:33:14 -0400 Subject: [PATCH] Rename 'result' field on the Task model to 'error'. closes #2675 https://pulp.plan.io/issues/2675 --- app/pulp/app/models/task.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/pulp/app/models/task.py b/app/pulp/app/models/task.py index 1af6fc6377..3ff66b89c4 100644 --- a/app/pulp/app/models/task.py +++ b/app/pulp/app/models/task.py @@ -123,7 +123,7 @@ class Task(Model): finished_at (models.DateTimeField): The time the task finished executing non_fatal_errors (pulp.app.fields.JSONField): Dictionary of non-fatal errors that occurred while task was running. - result (pulp.app.fields.JSONField): Return value of the task + error (pulp.app.fields.JSONField): Fatal errors generated by the task Relations: @@ -152,7 +152,7 @@ class Task(Model): finished_at = models.DateTimeField(null=True) non_fatal_errors = JSONField(default=list) - result = JSONField(null=True) + error = JSONField(null=True) parent = models.ForeignKey("Task", null=True, related_name="spawned_tasks") worker = models.ForeignKey("Worker", null=True, related_name="tasks") @@ -170,17 +170,16 @@ def set_running(self): self.started_at = timezone.now() self.save() - def set_completed(self, result): + def set_completed(self, error): """ Set this Task to the completed state, save it, and log output in warning cases. This updates the :attr:`finished_at` and sets the :attr:`state` to :attr:`COMPLETED`. Args: - result (dict): The result to save on the :class:`~pulp.app.models.Task` + error (dict): Fatal errors to save on the :class:`~pulp.app.models.Task` """ self.finished_at = timezone.now() - self.result = result # Only set the state to finished if it's not already in a complete state. This is # important for when the task has been canceled, so we don't move the task from canceled @@ -198,7 +197,7 @@ def set_failed(self, exc, einfo): Set this Task to the failed state and save it. This updates the :attr:`finished_at` attribute, sets the :attr:`state` to - :attr:`FAILED`, and sets the :attr:`result` attribute. + :attr:`FAILED`, and sets the :attr:`error` attribute. Args: exc (Exception): The exception raised by the task. @@ -207,7 +206,7 @@ def set_failed(self, exc, einfo): """ self.state = Task.FAILED self.finished_at = timezone.now() - self.result = exception_to_dict(exc, einfo.traceback) + self.error = exception_to_dict(exc, einfo.traceback) self.save()