pulp / pulpcore

Pulp 3 pulpcore package https://pypi.org/project/pulpcore/
GNU General Public License v2.0
302 stars 116 forks source link

Make the artifact create endpoint idempotent #5780

Open daviddavis opened 2 months ago

daviddavis commented 2 months ago

The package creation endpoints are idempotent so I wonder if the artifact create endpoint should be as well. Currently, you get a 400 error if you attempt to upload an artifact that already exists:

$ https --form :/pulp/api/v3/artifacts/ file@~/frigg_1.0_ppc64.deb
{
    "non_field_errors": [
        "Artifact with sha256 checksum of 'a20723d4d174abecc0001bbbe183d04fc26b2ca30d77d87b5c4c9f3be35b67ee' already exists."
    ]
}
mdellweg commented 2 months ago

Not opposed to it, but IMHO the artifacts api should completely be deprecated for removal in pulp 4. Having the user care about bare artifacts adds an unnecessary layer of confusion to the usage patterns of pulp.

dkliban commented 2 months ago

I discussed this issue with @daviddavis on chat. He's using this API for uploading artifacts that are needed to create multi-artifact source packages in pulp_deb. A change in pulp_deb API for source packages would be appreciated. @quba42 , what do you think about that?

quba42 commented 2 months ago

Have other plugins already solved this? In other words is there already an API endpoint somewhere for creating a multi-artifact content without having to separately create the artifacts first? That is how I understood the request.

dkliban commented 2 months ago

I don't think we have an example of this anywhere else. @dralley @ggainey does RPM have anything like this?

quba42 commented 2 months ago

So I just had a look at the pulp_deb Source Package API endpoint, and it expects you to provide the .dsc file as an artifact, and then it will just loop over the files referenced in that .dsc file, expecting those to already exist as artifacts in Pulp.

Does anyone have any ideas how one might provide a content API endpoint with multiple uploads to create a content and multiple artifacts from?

I did not think about this before, and if it does not already exist elsewhere, I am not at all confident I know a good approach. :smile:

mdellweg commented 2 months ago

I think the multipart body can accept multiple files in one request just fine. Not sure if DRF covers for that. Also I would kind of expect that for each file you can either upload a file, specify an upload or (for the time being) an artifact.

Somehow we are derailing from the original ask: "Should the Artifact upload be idempotent?" And we can do that.