Story #5367
closedAs a user, I can have a sync option that retains the latest N packages of the same name
100%
Description
Goal¶
Provide a way to specify that for example only the latest N versions of every package with the name name are retained in the repository.
Sync time option retain-old-count¶
RPM sync will take a sync-time option named retain-old-count
with an integer value. This will cause N versions of a package to be retained. Two packages with the same name are considered the same package.
When used the integer value needs to be validated as an Integer that is greater than 0 and raise a Validation error otherwise.
Determining latest¶
Latest is determine by comparison of the <epoch, version, and release> triplet.
Incompatibility with mirror=True¶
The mirror=True option requires the retained packages to be a mirror of the remote so mirror=True cannot to be used when the user is also specifying retain-old-count
.
This needs to raise a Validation error if mirror=True and retain-old-count are specified together.
Pulp2 Equivalent¶
In Pulp2 it was called retain-old-count
.
Implementation¶
The RpmDeclarativeVersion should implement a create method that will mimic the one from core The only difference in the RPM one is that instead of adding ContentUnassociation as the last stage a new custom RPM stage should be implemented. Let's call that stage ContentUnassociationRetainN (as a working name).
The ContentUnassociationRetainN stage works in place of the ContentUnassocaition in core and runs with similar assumptions. Specifically it receives queryset objects not DeclarativeContent objects like earlier stages in the pipeline. You can see those emitted from the stage before
The ContentUnassicationRetainN stage needs to further filter these unassociation querysets to filter out units that would be removed but shouldn't be due to their NEVRA. The content associated with the repository is already in place so between the queryset of items marked for removal and the content that is "known good" being outside of those querysets one should be able to compute the previous N versions somehow.
I think we can start with something inefficient but correct and improve it over time through profiling and the explain operator.
Katello Related Issue¶
Related issues
Add a retention policy feature for purging older packages
closes: #5367 https://pulp.plan.io/issues/5367