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

[CP] Katello 4.16.0.rc2 Cherry Picks #11332

Merged
merged 11 commits into from
Mar 4, 2025
Merged
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
17 changes: 9 additions & 8 deletions app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ KT.hosts.onKatelloHostEditLoad = function(){

$.each(prefixes, function(index, prefix) {
$.each(attributes, function(attrIndex, attribute) {
$('body').on('change', '#' + prefix + '_' + attribute, function () {
$('body').on('select2:select select2:unselecting', '#' + prefix + '_' + attribute, function () {
KT.hosts.toggle_installation_medium();
});
});
});

$('body').on('change', '#content_source_id', function () {
$('body').on('select2:select select2:unselecting', '#content_source_id', function () {
KT.hosts.contentSourceChanged();
KT.hosts.toggle_installation_medium();
});
Expand Down Expand Up @@ -266,14 +266,15 @@ KT.hosts.on_synced_content_dropdown_change = function() {

KT.hosts.set_install_media_bindings = function() {
// reset the host medium id
$("#host_medium_id").on("change", KT.hosts.on_install_media_dropdown_change);
$("#s2id_host_medium_id").on("change", KT.hosts.on_install_media_dropdown_change);
$("#hostgroup_medium_id").on("change", KT.hosts.on_install_media_dropdown_change);
$("#s2id_hostgroup_medium_id").on("change", KT.hosts.on_install_media_dropdown_change);
$("#host_medium_id").on("select2:select", KT.hosts.on_install_media_dropdown_change);
$("#s2id_host_medium_id").on("select2:select", KT.hosts.on_install_media_dropdown_change);
$("#hostgroup_medium_id").on("select2:select", KT.hosts.on_install_media_dropdown_change);
$("#s2id_hostgroup_medium_id").on("select2:select", KT.hosts.on_install_media_dropdown_change);
};

KT.hosts.set_synced_content_bindings = function() {
KT.hosts.get_synced_content_dropdown().change(KT.hosts.on_synced_content_dropdown_change);
KT.hosts
.get_synced_content_dropdown()
.on('select2:select', KT.hosts.on_synced_content_dropdown_change);
};

KT.hosts.set_media_selection_bindings = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ def repackage_message
end

rescue_from RestClient::Exception do |e|
Rails.logger.error pp_exception(e)
# Log BLOB_UNKNOWN errors as info.
# These 404s occur as part of podman push's blob lookup and should not be reported as errors.
if e.http_code == 404
body = JSON.parse(e.http_body) rescue {}
if body["errors"]&.any? { |error| error["code"] == "BLOB_UNKNOWN" }
Rails.logger.info pp_exception(e)
else
Rails.logger.error pp_exception(e)
end
else
Rails.logger.error pp_exception(e)
end

if request_from_katello_cli?
render json: { errors: [e.http_body] }, status: e.http_code
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def plan(extended_repo_map, smart_proxy, options = {})
solve_dependencies: solve_dependencies)
plan_action(Actions::Pulp3::Repository::SaveVersions, extended_repo_map.values.pluck(:dest_repo),
tasks: copy_action.output[:pulp_tasks])
repo_id_map = {}
extended_repo_map.each do |source_repos, dest_repo_map|
repo_id_map[source_repos.first.id] = dest_repo_map[:dest_repo].id if dest_repo_map[:filters].blank?
end
plan_self(repo_id_map: repo_id_map)
end
else
repo_id_map = {}
Expand Down
4 changes: 2 additions & 2 deletions app/models/katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class ContentView < Katello::Model
:through => :content_view_environments
has_many :content_facets, :class_name => "Katello::Host::ContentFacet", :through => :content_view_environment_content_facets,
:inverse_of => :content_views
has_many :hosts, :class_name => "::Host::Managed", :through => :content_facets,
has_many :hosts, -> { reorder(:id).distinct }, :class_name => "::Host::Managed", :through => :content_facets,
:inverse_of => :content_views

has_many :content_view_environment_activation_keys, :class_name => "Katello::ContentViewEnvironmentActivationKey",
:through => :content_view_environments
has_many :activation_keys, :class_name => "Katello::ActivationKey", :through => :content_view_environment_activation_keys,
has_many :activation_keys, -> { reorder(:id).distinct }, :class_name => "Katello::ActivationKey", :through => :content_view_environment_activation_keys,
:inverse_of => :content_views

has_many :hostgroup_content_facets, :class_name => "Katello::Hostgroup::ContentFacet",
Expand Down
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
2 changes: 2 additions & 0 deletions app/views/katello/api/v2/content_facet/show.json.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ child :content_facet => :content_facet_attributes do
node(:view_activation_keys) { user.can?("view_activation_keys") }
node(:view_products) { user.can?("view_products") }
node(:create_bookmarks) { user.can?("create_bookmarks") }
node(:view_smart_proxies) { user.can?("view_smart_proxies") }
node(:view_capsule_content) { user.can?("view_capsule_content") }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
option.kt-cv { margin-left: 1em; }
</style>
<% spinner_path = asset_path('spinner.gif') %>
<% can_change_content_source = User.current.can?("view_smart_proxies") && User.current.can?("view_capsule_content") %>

<% if edit_action? && !using_hostgroups_page? && !using_discovered_hosts_page? %>
<% if edit_action? && !using_hostgroups_page? && !using_discovered_hosts_page? && can_change_content_source %>
<div style="margin-left: 270px">
<%= link_to _("Change content source"), "/change_host_content_source?fromPage=hostEdit&host_id=#{@host.id}&initialContentSourceId=#{@host.content_source_id}" %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h2 translate>New Activation Key</h2>
<select ng-hide="contentViews.length === 0 || activationKey.environment === undefined "
id="content_view_id"
name="content_view_id"
ng-required="activationKey.environment"
ng-model="activationKey.content_view_id"
ng-options="contentView.id as contentView.name for contentView in contentViews"
autofocus>
Expand All @@ -64,7 +65,7 @@ <h2 translate>New Activation Key</h2>
The selected environment contains no Content Views, please select a different environment.
</span>
<span class="help-block" ng-show="activationKey.environment === undefined" translate>
Please select an environment.
Please select a lifecycle environment. Lifecycle environment and content view must be provided together.
</span>
</div>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkReleaseVersi
}

$scope.selected = {
release: undefined
release: ""
};
$scope.fetchingReleases = true;

Organization.releaseVersions({id: CurrentOrganization}, function (response) {
$scope.releases = response.results;
// Add empty string to unset the release version
$scope.releases.unshift("");
$scope.fetchingReleases = false;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h4 translate>Assign Release Version</h4>
<i ng-show="fetchingReleases" class="fa fa-spinner inline-icon fa-spin"></i>
<select ng-hide="fetchingReleases || releases.length === 0"
type="select"
ng-options="release for release in releases"
ng-options="release === '' ? '(unset)' : release for release in releases"
ng-model="selected.release">
</select>

Expand Down
Loading
Loading