Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross-domain content assertion #5970

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/content-assert.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an assertion on all content being added/removed in a repository version is of the same domain.
12 changes: 10 additions & 2 deletions pulpcore/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,11 @@ def add_content(self, content):
if self.complete:
raise ResourceImmutableError(self)

assert not content.exclude(pulp_domain_id=get_domain_pk()).exists()
assert (
not Content.objects.filter(pk__in=content)
.exclude(pulp_domain_id=get_domain_pk())
.exists()
)
repo_content = []
to_add = set(content.values_list("pk", flat=True)) - set(
self.content.values_list("pk", flat=True)
Expand Down Expand Up @@ -1026,7 +1030,11 @@ def remove_content(self, content):

if not content or not content.count():
return
assert not content.exclude(pulp_domain_id=get_domain_pk()).exists()
assert (
not Content.objects.filter(pk__in=content)
.exclude(pulp_domain_id=get_domain_pk())
.exists()
)

# Normalize representation if content has already been added in this version.
# Undo addition by deleting the RepositoryContent.
Expand Down