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

Fixes #38061 - Use advanced copy API for deb content #11247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading