Skip to content

Commit

Permalink
Fixes #38061 - Use advanced copy API for deb content
Browse files Browse the repository at this point in the history
This fixes deb content filters with structured APT enabled.
  • Loading branch information
quba42 committed Dec 4, 2024
1 parent c79f9b1 commit b081944
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
34 changes: 16 additions & 18 deletions app/services/katello/pulp3/repository/apt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
Expand Down
14 changes: 0 additions & 14 deletions test/services/katello/pulp3/repository/apt/apt_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b081944

Please sign in to comment.