Skip to content

Fix a cache invalidation issue with Distributions serving publications indirectly via repository_version - #8008

Open
dralley wants to merge 1 commit into
pulp:mainfrom
dralley:cache-invalidation-bug
Open

Fix a cache invalidation issue with Distributions serving publications indirectly via repository_version#8008
dralley wants to merge 1 commit into
pulp:mainfrom
dralley:cache-invalidation-bug

Conversation

@dralley

@dralley dralley commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Make sure we flush the cache (and update DistributedPublication) for
publications which were indirectly served via
Distribution.repository_version, rather than directly.

closes #7993

Comment thread pulpcore/app/models/publication.py
@dralley
dralley force-pushed the cache-invalidation-bug branch 2 times, most recently from 023e815 to 33db05a Compare August 25, 2026 05:00
@dralley

dralley commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Not quite ready for review yet.

@dralley
dralley force-pushed the cache-invalidation-bug branch 3 times, most recently from 2b2fe3f to a4a3d27 Compare August 31, 2026 03:36
Comment thread pulpcore/app/models/publication.py Outdated
return
DistributedPublication(distribution=self, publication=pub).save()
# Check if this publication is already the active one
already_current = DistributedPublication.objects.filter(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this whole block be in a transaction?

…ions

Distributions serving via `repository_version` were missed by cache invalidation
and DistributedPublication tracking when publications were created or deleted.

Also fixes DistributedPublication to reactivate (clear `expires_at`) when switching
back to a recently-superseded publication, instead of creating a duplicate record.

closes pulp#7993
Assisted-By: Claude Opus 4.6
@dralley
dralley force-pushed the cache-invalidation-bug branch from 9b956cc to 5391c08 Compare September 1, 2026 18:07
@dralley
dralley requested a review from gerrod3 September 1, 2026 18:07
@dralley
dralley marked this pull request as ready for review September 1, 2026 18:07

@gerrod3 gerrod3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new cache invalidation scenario looks correct. I don't know enough about DistributedPublications to comment on the code changes there.

Comment on lines +423 to +424
@pytest.mark.django_db
class TestCacheInvalidationOnDistributionUpdate:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the cache invalidation tests belong here? Should they be in their own file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be reasonable to separate them but they're also somewhat coupled in the sense that a significant amount of logic is basically shared between the two and the scenarios are basically the same. If you feel strongly we can do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants