Actions
Issue #2969
closedprogress reports omitted by task API
Start date:
Due date:
Estimated time:
Severity:
3. High
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 24
Quarter:
Description
I discovered this bug while writing the pulp_example plugin. The sync code that could demonstrate this problem has not been merged (yet). HOwever, the issue can be demonstrated by adding the following diff to Pulp.
diff --git a/platform/pulpcore/app/tasks/importer.py b/platform/pulpcore/app/tasks/importer.py
index 0ef18a8..24d69b5 100644
--- a/platform/pulpcore/app/tasks/importer.py
+++ b/platform/pulpcore/app/tasks/importer.py
@@ -29,13 +29,18 @@ def update(importer_id, app_label, serializer_name, data=None, partial=False):
due to validation error. This theoretically should never occur since validation is
performed before the task is dispatched.
"""
- instance = models.Importer.objects.get(id=importer_id).cast()
- data_querydict = QueryDict('', mutable=True)
- data_querydict.update(data)
- serializer_class = get_plugin_config(app_label).named_serializers[serializer_name]
- serializer = serializer_class(instance, data=data_querydict, partial=partial)
- serializer.is_valid(raise_exception=True)
- serializer.save()
+ from pulpcore.plugin.models import ProgressBar
+ progress_bar = ProgressBar(message="Updating importer", total=1)
+ progress_bar.save()
+ with progress_bar:
+ instance = models.Importer.objects.get(id=importer_id).cast()
+ data_querydict = QueryDict('', mutable=True)
+ data_querydict.update(data)
+ serializer_class = get_plugin_config(app_label).named_serializers[serializer_name]
+ serializer = serializer_class(instance, data=data_querydict, partial=partial)
+ serializer.is_valid(raise_exception=True)
+ serializer.save()
+ progress_bar.increment()
Assuming that pulp 3 is running on localhost:1234, you can create a repository:
http POST http://localhost:1234/api/v3/repositories/ name=mycoolrepo notes:={} scratchpad:={}
Add a file importer:
http POST http://localhost:1234/api/v3/repositories/mycoolrepo/importers/file/ name=mycoolimporter download_policy='immediate' repository='http://localhost:1234/api/v3/repositories/mycoolrepo/'
Modify the importer:
[vagrant@pulp3 pulp]$ http PATCH http://localhost:1234/api/v3/repositories/mycoolrepo/importers/file/mycoolimporter/ download_policy='on_demand'
HTTP/1.0 202 Accepted
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Length: 135
Content-Type: application/json
Date: Thu, 10 Aug 2017 15:37:42 GMT
Server: WSGIServer/0.2 CPython/3.5.3
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
[
{
"_href": "http://localhost:1234/api/v3/tasks/36ee48dc-0a41-42b3-bd99-b4f222cbd5b9/",
"task_id": "36ee48dc-0a41-42b3-bd99-b4f222cbd5b9"
}
]
The last command returned a task id and a URL for that task. A GET request of that URL returns the task.
[vagrant@pulp3 pulp]$ http http://localhost:1234/api/v3/tasks/36ee48dc-0a41-42b3-bd99-b4f222cbd5b9/
HTTP/1.0 200 OK
Allow: GET, OPTIONS
Content-Length: 349
Content-Type: application/json
Date: Thu, 10 Aug 2017 15:39:53 GMT
Server: WSGIServer/0.2 CPython/3.5.3
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
{
"_href": "http://localhost:1234/api/v3/tasks/36ee48dc-0a41-42b3-bd99-b4f222cbd5b9/",
"error": null,
"finished_at": "2017-08-10T15:37:43.044201Z",
"group": null,
"non_fatal_errors": [],
"parent": null,
"started_at": "2017-08-10T15:37:42.992822Z",
"state": "completed",
"tags": [],
"worker": "http://localhost:1234/api/v3/workers/reserved_resource_worker_1@pulp3.dev/"
}
The task should include the progress report that was generated. However, it does not. The progress report does exist in the database though:
[vagrant@pulp3 pulp]$ psql --u pulp
psql (9.5.7)
Type "help" for help.
pulp=# select * from pulp_app_progressreport ;
id | message | state | total | done | suffix | task_id
--------------------------------------+------------------------------------------------------------+-----------+-------+------+--------+--------------------------------------
5fac01d4-f07e-4fda-b635-9ba468e04183 | Updating importer | completed | 1 | 1 | | 36ee48dc-0a41-42b3-bd99-b4f222cbd5b9
Actions
Update task to serialize progress_report
closes #2969 https://pulp.plan.io/issues/2969