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

Taught prune() to call remove_content() with a Content queryset. #3779

Closed
wants to merge 1 commit into from
Closed
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/3778.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix traceback from prune() call discovered after `pulp/pulpcore#5934` addressed.
4 changes: 3 additions & 1 deletion pulp_rpm/app/tasks/prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pulpcore.plugin.models import ProgressReport
from pulpcore.plugin.constants import TASK_STATES
from pulpcore.plugin.models import (
Content,
GroupProgressReport,
RepositoryContent,
TaskGroup,
Expand Down Expand Up @@ -91,8 +92,9 @@ def prune_repo_packages(repo_pk, keep_days, dry_run):
):
log.debug(f'{p["name"]}-{p["epoch"]}:{p["version"]}-{p["release"]}.{p["arch"]}')
else:
content_q = Content.objects.filter(pk__in=target_ids_q)
with repo.new_version(base_version=None) as new_version:
new_version.remove_content(target_ids_q)
new_version.remove_content(content_q)
data["done"] = to_be_removed

pb = ProgressReport(**data)
Expand Down
8 changes: 2 additions & 6 deletions pulp_rpm/tests/functional/api/test_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,13 @@ def test_object_creation(
rpm_repository_api.create(repo_body, pulp_domain=domain.name)
assert e.value.status == 400
# What key should this error be under? non-field-errors seems wrong
assert json.loads(e.value.body) == {
"non_field_errors": [f"Objects must all be apart of the {domain_name} domain."]
}
assert "non_field_errors" in e.value.body

with pytest.raises(ApiException) as e:
sync_body = {"remote": default_remote.pulp_href}
rpm_repository_api.sync(repo.pulp_href, sync_body)
assert e.value.status == 400
assert json.loads(e.value.body) == {
"non_field_errors": [f"Objects must all be apart of the {domain_name} domain."]
}
assert "non_field_errors" in e.value.body


@pytest.mark.parallel
Expand Down
Loading