Story #5367
Updated by bmbouter about 5 years ago
h3. Goal Provide a way to specify that for example only the latest N last two versions of every package with the name name are retained in the repository. h3. Sync time option retain-old-count get synced. RPM sync will take a sync-time option named <code>retain-old-count</code> 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. https://projects.theforeman.org/issues/16154 When used the integer value needs to be validated as an Integer that is greater than 0 and raise a Validation error otherwise. h3. Determining latest Latest is determine by comparison of the <epoch, version, and release> triplet. h3. 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 <code>retain-old-count</code>. This needs to raise a Validation error if mirror=True and AKA: retain-old-count are specified together. h3. Pulp2 Equivalent In Pulp2 it was called <code>retain-old-count</code>. h3. Implementation The RpmDeclarativeVersion should implement a create method that will mimic "the one from core":https://github.com/pulp/pulpcore-plugin/blob/master/pulpcore/plugin/stages/declarative_version.py#L166 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":https://github.com/pulp/pulpcore-plugin/blob/ca1ae38a62272b228e05677164105f64558ccd7c/pulpcore/plugin/stages/association_stages.py#L74-L87 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":https://github.com/pulp/pulpcore-plugin/blob/ca1ae38a62272b228e05677164105f64558ccd7c/pulpcore/plugin/stages/association_stages.py#L53 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. h3. Katello Related Issue https://projects.theforeman.org/issues/16154 pulp2