Should publications keep certain repository versions from being removed?

Problem:
I have an RPM repository which is filled by Jenkins. As we have thousands of Jenkins jobs (each one producing an RPM package), there may be hundreds of new Pulp repository versions a day.

Every now and then (e.g. each hour) I provide a new snapshot of the repository to our users, by creating a new publication and then updating the distribution to point to the new publication.

Now I noticed, that the repositories “retain_repo_versions” setting may remove the version which is currently referenced by a publication (and maybe a distribution by a publication).

I have thought of a publication as sort of a tag for a certain repository version. Now I wonder if repository versions which are referenced by publications / distributions shall be excluded from the retain_repo_versions purging. This is what I would have expected.

What do others think about this?

Thanks,
Rolf

2 Likes

This is a tough one. Publications can just too easily be forgotten about, so having a publication for each repository version would basically render retain_repo_versions non-functional.
However, i can see the need to somehow bless or protect distinct repo versions from auto-cleanup.
Protecting the version only by having a distribution would mean that only versions that are actually served are safe.
Whatever condition to prevent deletion we come up with, i would want us to enforce it on both manual and automatic version deletion.

1 Like

Thanks for the prompt reply. So what can I do to help? Shall I create a Github issue for this? In pulpcore?

2 Likes

Yes, that would be a fine move. Can you link this thread to keep the discussions together somehow?

This issue indirectly is related to this one Should we keep using FK with on_delete=SET_NULL?

Is there a way to (re-)set the retain-repo-versions field of a repository to null? The rest api and pulp-cli require an integer >= 1:

$ pulp rpm repository update --href /pulp/api/v3/repositories/rpm/rpm/96717c8c-6038-4dad-99f5-7d605b9cc7d9/ --retain-repo-versions null
Error: {"retain_repo_versions":["A valid integer is required."]}

$ pulp rpm repository update --href /pulp/api/v3/repositories/rpm/rpm/96717c8c-6038-4dad-99f5-7d605b9cc7d9/ --retain-repo-versions 0
Error: {"retain_repo_versions":["Ensure this value is greater than or equal to 1."]}

I agree, it’s not completely intuitive, but --retain-repo-versions "" should work. In the CLI, the empty string will be translated to nullifying in the REST API.
Also the REST API accepts null with the content type set to application/json.

That worked. Thank you.