Skip to content

Commit

Permalink
Rename 'result' field on the Task model to 'error'.
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Apr 14, 2017
1 parent eeb2877 commit cda52cf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/pulp/app/models/task.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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()


Expand Down

0 comments on commit cda52cf

Please sign in to comment.