From 002a5436b5d67fefc36fc97351f5cab5e33dc3b7 Mon Sep 17 00:00:00 2001 From: Ian Ballou Date: Tue, 4 Feb 2025 13:47:46 -0500 Subject: [PATCH] Fixes #38175 - limit errata application to the applicable (#11295) --- app/models/katello/concerns/host_managed_extensions.rb | 4 ++-- .../foreman/job_templates/install_errata_by_search_query.erb | 2 +- ...stall_errata_by_search_query_-_katello_ansible_default.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/katello/concerns/host_managed_extensions.rb b/app/models/katello/concerns/host_managed_extensions.rb index 6b0be959ff8..5c5f7c0017a 100644 --- a/app/models/katello/concerns/host_managed_extensions.rb +++ b/app/models/katello/concerns/host_managed_extensions.rb @@ -589,8 +589,8 @@ def deb_names_for_job_template(action:, search:) end end - def advisory_ids(search:, check_installable_for_host: true) - errata_scope = check_installable_for_host ? ::Katello::Erratum.installable_for_hosts([self]) : ::Katello::Erratum + def advisory_ids(search:) + errata_scope = ::Katello::Erratum.installable_for_hosts([self]) ids = errata_scope.search_for(search).pluck(:errata_id) if ids.empty? fail _("Cannot install errata: No errata found for search term '%s'") % search diff --git a/app/views/foreman/job_templates/install_errata_by_search_query.erb b/app/views/foreman/job_templates/install_errata_by_search_query.erb index fc86535b933..3ef5a1bf809 100644 --- a/app/views/foreman/job_templates/install_errata_by_search_query.erb +++ b/app/views/foreman/job_templates/install_errata_by_search_query.erb @@ -15,7 +15,7 @@ foreign_input_sets: exclude: action,package %> -<% advisory_ids = @host.advisory_ids(search: input("Errata search query"), check_installable_for_host: false) -%> +<% advisory_ids = @host.advisory_ids(search: input("Errata search query")) -%> <% render_error(N_("No errata matching given search query")) if !input("Errata search query").blank? && advisory_ids.blank? -%> # RESOLVED_ERRATA_IDS=<%= advisory_ids.join(',') %> diff --git a/app/views/foreman/job_templates/install_errata_by_search_query_-_katello_ansible_default.erb b/app/views/foreman/job_templates/install_errata_by_search_query_-_katello_ansible_default.erb index 7b4bceba377..5cbb894bc82 100644 --- a/app/views/foreman/job_templates/install_errata_by_search_query_-_katello_ansible_default.erb +++ b/app/views/foreman/job_templates/install_errata_by_search_query_-_katello_ansible_default.erb @@ -12,7 +12,7 @@ template_inputs: required: false %> -<% advisory_ids = @host.advisory_ids(search: input("Errata search query"), check_installable_for_host: true) -%> +<% advisory_ids = @host.advisory_ids(search: input("Errata search query")) -%> <% render_error(N_("No errata matching given search query")) if !input("Errata search query").blank? && advisory_ids.blank? -%> # RESOLVED_ERRATA_IDS=<%= advisory_ids.join(',') %>