Skip to content

Commit

Permalink
Fixes bug where replication task would delete repositories accross do…
Browse files Browse the repository at this point in the history
…mains.

fixes: #4158
(cherry picked from commit 6235aec)
  • Loading branch information
dkliban committed Jul 27, 2023
1 parent c60f6f6 commit 267ddea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES/4158.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where repositories were getting deleted accross domains.
8 changes: 6 additions & 2 deletions pulpcore/app/replica.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,19 @@ def remove_missing(self, names):
)

# Remove all the repositories and remotes of the missing distributions
repos_to_delete = self.repository_model_cls.objects.exclude(name__in=names)
repos_to_delete = self.repository_model_cls.objects.filter(pulp_domain=self.domain).exclude(
name__in=names
)
for repo in repos_to_delete:
dispatch(
general_delete,
task_group=self.task_group,
exclusive_resources=[repo],
args=(repo.pk, self.app_label, self.repository_serializer_name),
)
remotes_to_delete = self.remote_model_cls.objects.exclude(name__in=names)
remotes_to_delete = self.remote_model_cls.objects.filter(pulp_domain=self.domain).exclude(
name__in=names
)
for remote in remotes_to_delete:
dispatch(
general_delete,
Expand Down
8 changes: 4 additions & 4 deletions pulpcore/tests/functional/api/test_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@pytest.mark.parallel
def test_replication(
domain_factory,
domains_api_client,
bindings_cfg,
upstream_pulp_api_client,
monitor_task_group,
pulp_settings,
Expand All @@ -20,11 +20,11 @@ def test_replication(
# Create an Upstream Pulp in the non-default domain
upstream_pulp_body = {
"name": str(uuid.uuid4()),
"base_url": domains_api_client.api_client.configuration.host,
"base_url": bindings_cfg.host,
"api_root": pulp_settings.API_ROOT,
"domain": "default",
"username": domains_api_client.api_client.configuration.username,
"password": domains_api_client.api_client.configuration.password,
"username": bindings_cfg.username,
"password": bindings_cfg.password,
}
upstream_pulp = gen_object_with_cleanup(
upstream_pulp_api_client, upstream_pulp_body, pulp_domain=non_default_domain.name
Expand Down

0 comments on commit 267ddea

Please sign in to comment.