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 <[email protected]>

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 20, 2025
1 parent d0ec81e commit a037083
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/models/katello/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,8 @@ def in_content_view?(content_view)
end

def deb_content_url_options
return '' unless version_href
return '' unless self.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
21 changes: 18 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,26 @@ 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?
version = api.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!({ 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

0 comments on commit a037083

Please sign in to comment.