Summary
Distributions that serve content via a repository_version are not handled when a publication is created or deleted. Their content cache is not invalidated and their DistributedPublication fallback records are not updated, even though the publication they indirectly serve has changed.
A distribution with SERVE_FROM_PUBLICATION resolves its served publication three ways (see get_repository_publication_and_version): explicit publication, latest publication of a repository_version, or latest publication of the latest version of a repository. When a publication is created or deleted, the publication served indirectly can change without the distribution itself changing — but the create/delete logic only accounts for the repository case, missing repository_version.
Broken code
Publication create (__exit__) — the DistributedPublication refresh loop and the cache-invalidation filter only match repository, never repository_version:
Publication delete — publication.py#L158-L180: invalidates the distributions of the whole repository when this is the latest publication, but never the distributions serving this publication's repository_version directly.
Impact
A user distributing via repository_version (or relying on the DistributedPublication fallback) can be served stale cached content after a new publication is created or after the serving publication is deleted, until the cache expires on its own.
Fix
Filter on both repository and repository_version in the create path, reuse an idempotent set_distributed_publication() for the DistributedPublication refresh, and add a repository_version branch to the delete path (invalidate only when the deleted publication is the latest for that version). Covered by new unit tests in pulpcore/tests/unit/models/test_publication_retention.py.
Summary
Distributions that serve content via a
repository_versionare not handled when a publication is created or deleted. Their content cache is not invalidated and theirDistributedPublicationfallback records are not updated, even though the publication they indirectly serve has changed.A distribution with
SERVE_FROM_PUBLICATIONresolves its served publication three ways (seeget_repository_publication_and_version): explicitpublication, latest publication of arepository_version, or latest publication of the latest version of arepository. When a publication is created or deleted, the publication served indirectly can change without the distribution itself changing — but the create/delete logic only accounts for therepositorycase, missingrepository_version.Broken code
Publication create (
__exit__) — theDistributedPublicationrefresh loop and the cache-invalidation filter only matchrepository, neverrepository_version:Publication delete — publication.py#L158-L180: invalidates the distributions of the whole
repositorywhen this is the latest publication, but never the distributions serving this publication'srepository_versiondirectly.Impact
A user distributing via
repository_version(or relying on the DistributedPublication fallback) can be served stale cached content after a new publication is created or after the serving publication is deleted, until the cache expires on its own.Fix
Filter on both
repositoryandrepository_versionin the create path, reuse an idempotentset_distributed_publication()for the DistributedPublication refresh, and add arepository_versionbranch to the delete path (invalidate only when the deleted publication is the latest for that version). Covered by new unit tests inpulpcore/tests/unit/models/test_publication_retention.py.