Skip to content

Commit

Permalink
Fixes #38231 - Provide fallback to simple deb publish
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Bucher <bucher@atix.de>

We have encountered some rare corner cases where pulp_deb repos created
using older Katello versions do not have any PRC structure content. In
such cases we fall back to simple publishing. In the future we may
replace this with a data repair migration on the pulp_deb side.
  • Loading branch information
quba42 committed Feb 24, 2025
1 parent d0ec81e commit 140ff95
Show file tree
Hide file tree
Showing 13 changed files with 11,028 additions and 8,154 deletions.
1 change: 1 addition & 0 deletions app/models/katello/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ def in_content_view?(content_view)

def deb_content_url_options
return '' unless version_href
return '' if backend_service(SmartProxy.pulp_primary).version_missing_structure_content?

components = deb_pulp_components.join(',')
distributions = deb_pulp_distributions.join(',')
Expand Down
24 changes: 21 additions & 3 deletions app/services/katello/pulp3/repository/apt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def sync_url_params(sync_options)
end

def mirror_remote_options
distributions = if repo.deb_using_structured_apt?
distributions = if repo.deb_using_structured_apt? && !version_missing_structure_content?
repo.deb_pulp_distributions.join(' ')
else
'default'
Expand All @@ -48,11 +48,29 @@ def mirror_remote_options
super.merge({distributions: distributions})
end

def version_missing_structure_content?
# There may be old pulp_deb repo versions that have no package_release_components to go with the packages.
# This could be because packages were uploaded with Katello < 4.12
# It may also affect filtered CV versions created with very old Katello versions.
# This method can identify such cases, so that we may fall back to simple publishing.
return false if repo.version_href.blank?
# We cannot just use api here, because this is sometimes the proxy api, and we always want to talk to the primary!
api_primary = self.class.instance_for_type(repo, ::SmartProxy.pulp_primary).api
version = api_primary.repository_versions_api.read(repo.version_href)
apt_content_types = version&.content_summary&.present&.keys
return apt_content_types.include?('deb.package') && !apt_content_types.include?('deb.package_release_component')
end

def publication_options(repository)
ss = api.signing_services_api.list(name: SIGNING_SERVICE_NAME).results
popts = super(repository)
popts.merge!({ structured: true })
popts.merge!({ simple: true }) unless repository.deb_using_structured_apt?
if version_missing_structure_content?
popts.merge!({ structured: false })
popts.merge!({ simple: true })
else
popts.merge!({ structured: true })
popts.merge!({ simple: true }) unless repository.deb_using_structured_apt?
end
popts[:signing_service] = ss[0].pulp_href if ss && ss.length == 1
popts
end
Expand Down

Large diffs are not rendered by default.

1,312 changes: 615 additions & 697 deletions test/fixtures/vcr_cassettes/actions/pulp3/apt_update/update_policy.yml

Large diffs are not rendered by default.

1,268 changes: 604 additions & 664 deletions test/fixtures/vcr_cassettes/actions/pulp3/apt_update/update_url.yml

Large diffs are not rendered by default.

1,194 changes: 466 additions & 728 deletions test/fixtures/vcr_cassettes/actions/pulp3/apt_update_no_url/addurl.yml

Large diffs are not rendered by default.

616 changes: 312 additions & 304 deletions test/fixtures/vcr_cassettes/actions/pulp3/deb_upload/duplicate_upload.yml

Large diffs are not rendered by default.

Loading

0 comments on commit 140ff95

Please sign in to comment.