Skip to content

Cache and DistributedPublication not refreshed for repository_version distributions on publication create/delete #7993

Description

@dralley

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 deletepublication.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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions