[Pulp-dev] SingleArtifactContentUploadSerializer and task's created_resources

Brian Bouterse bmbouter at redhat.com
Thu Oct 3 22:32:46 UTC 2019

On Tue, Oct 1, 2019 at 5:37 PM Simon Baatz <gmbnomis at gmail.com> wrote:

> Using the new SingleArtifactContentUploadSerializer I noticed two
> things that I would like to get feedback on:
> 1. If a repo version is created (using the "repository" parameter),
>    "created_resources" of the respective task contains the content unit
>    and the new repo version, e.g.
> {
>     "_created": "2019-10-01T18:40:25.453340Z",
>     "_href": "/pulp/api/v3/tasks/9083f70c-7c28-4f76-8a78-a18b96c279de/",
>     "created_resources": [
> "/pulp/api/v3/repositories/6891aeb6-756d-4bb5-baaf-5d523c6dc16c/versions/1/",
> "/pulp/api/v3/content/cookbook/cookbooks/5a24108b-d763-4f7f-9eb7-a855e7355ac2/"
>     ],
>     "error": null,
> ...
>    However, actually three resources may be created: artifact,
>    content unit and repo version.  Why is the repo version included,
>    but not the artifact (which seems to be included in
>    "reserved_resources_record")?

Pulp typically doesn't report Artifacts being created except when the API
call is to specifically create an Artifact. For example, sync creates a
huge number of Artifacts, but  it don't report those. This isn't a very
consistent behavior, but it avoids the practical issue of an overwhelming
amount of Artifacts in some situations at least. Feedback on what would be
better here would be great.

Beyond Artifacts, sometimes a single file generates multiple content units,
e.g. moduleMD content, or in the future pulp_ansible collections creating
multiple roles they contain. general_create currently record only 1
CreatedResource is my understanding and I filed a bug about that here:
https://pulp.plan.io/issues/5539  Feedback on which solution would be best
would be good.

> 2.  What is the best way for the caller to tell the created resources
>    apart?  Look at the URLs?  Look at data returned by a GET?  (but
>    there is no common type-like field for these resources).

Yes inspecting the urls is the recommended way. It's a bit cumbersome
because you can't use an equality operator to compare, versus something
like django-rest-polymorphic
<https://github.com/apirobot/django-rest-polymorphic>. A `startswith`
should work well enough, or a `contains` in case of `/pulp/api/v3/` being
re-rooted later.

> _______________________________________________
> Pulp-dev mailing list
> Pulp-dev at redhat.com
> https://www.redhat.com/mailman/listinfo/pulp-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20191003/c9a84681/attachment.htm>

More information about the Pulp-dev mailing list