From b081944743e607ca3cc15573368d1171bd50a9be Mon Sep 17 00:00:00 2001 From: Quirin Pamp Date: Tue, 3 Dec 2024 18:43:17 +0100 Subject: [PATCH] Fixes #38061 - Use advanced copy API for deb content This fixes deb content filters with structured APT enabled. --- app/services/katello/pulp3/repository/apt.rb | 34 +++++++++---------- .../katello/pulp3/repository/apt/apt_test.rb | 14 -------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/app/services/katello/pulp3/repository/apt.rb b/app/services/katello/pulp3/repository/apt.rb index 2673e5209a0..9a5ded6c651 100644 --- a/app/services/katello/pulp3/repository/apt.rb +++ b/app/services/katello/pulp3/repository/apt.rb @@ -226,23 +226,6 @@ def copy_content_from_mapping(repo_id_map, _options = {}) multi_copy_units(repo_id_map, dependency_solving) end - def copy_units(content_unit_hrefs, remove_all) - remove_all = true if remove_all.nil? - tasks = [] - - if content_unit_hrefs.sort!.any? - first_slice = remove_all - content_unit_hrefs.each_slice(UNIT_LIMIT) do |slice| - tasks << add_content(slice, first_slice) - first_slice = false - end - # If we're merging composite cv repositories, don't clear out the Pulp repository. - elsif remove_all - tasks << remove_all_content - end - tasks - end - def copy_content_for_source(source_repository, options = {}) # copy_units_by_href(source_repository.debs.pluck(:pulp_id)) filters = ContentViewDebFilter.where(:id => options[:filter_ids]) @@ -261,7 +244,22 @@ def copy_content_for_source(source_repository, options = {}) content_unit_hrefs = whitelist_ids - blacklist_ids - copy_units(content_unit_hrefs.uniq, options[:remove_all]) + pulp_deb_copy_serializer = PulpDebClient::Copy.new + pulp_deb_copy_serializer.dependency_solving = false + pulp_deb_copy_serializer.config = [{ + source_repo_version: source_repository.version_href, + dest_repo: repository_reference.repository_href, + content: content_unit_hrefs, + }] + + remove_all = options[:remove_all] + remove_all = true if remove_all.nil? + + if remove_all + remove_all_content_from_repo(repository_reference.repository_href) + end + + copy_content_chunked(pulp_deb_copy_serializer) end def regenerate_applicability diff --git a/test/services/katello/pulp3/repository/apt/apt_test.rb b/test/services/katello/pulp3/repository/apt/apt_test.rb index ee7731c982a..8705240ee49 100644 --- a/test/services/katello/pulp3/repository/apt/apt_test.rb +++ b/test/services/katello/pulp3/repository/apt/apt_test.rb @@ -16,20 +16,6 @@ def teardown ensure_creatable(@repo, @proxy) end - def test_copy_units_does_not_clear_repo_during_composite_merger - service = Katello::Pulp3::Repository::Apt.new(@repo, @proxy) - service.expects(:remove_all_content).never - service.copy_units([], false) - end - - def test_copy_units_rewrites_missing_content_error - fake_content_href = '/pulp/api/v3/repositories/deb/apt/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/' - service = Katello::Pulp3::Repository::Apt.new(@repo, @proxy) - create_repo(@repo, @proxy) - error = assert_raises(::Katello::Errors::Pulp3Error) { service.copy_units([fake_content_href], false) } - assert_match(/Please run `foreman-rake katello:delete_orphaned_content` to fix the following repository: Debian 9 amd64./, error.message) - end - def test_remote_options @repo.root.url = "http://foo.com/bar/" service = Katello::Pulp3::Repository::Apt.new(@repo, @proxy)