Skip to content

Commit

Permalink
Fix cross-domain content assertion
Browse files Browse the repository at this point in the history
(cherry picked from commit c1d6081)
  • Loading branch information
gerrod3 authored and mdellweg committed Nov 11, 2024
1 parent fc7ac75 commit 429bc4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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 @@ -945,7 +945,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 @@ -987,7 +991,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

0 comments on commit 429bc4d

Please sign in to comment.