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 #38058 - Fix applied errata report #11252

Merged
merged 1 commit into from
Dec 10, 2024
Merged
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
10 changes: 3 additions & 7 deletions app/lib/katello/concerns/base_template_scope_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,17 @@ def load_errata_applications(filter_errata_type: nil, include_last_reboot: 'yes'
search_since = since.present? ? "ended_at > \"#{since}\"" : nil
search_result = status.present? && status != 'all' ? "result = #{status}" : nil
labels = 'label ^ (Actions::Katello::Host::Erratum::Install, Actions::Katello::Host::Erratum::ApplicableErrataInstall)'
select = 'foreman_tasks_tasks.*'

if Katello.with_remote_execution?
new_labels = 'label = Actions::RemoteExecution::RunHostJob AND remote_execution_feature.label ^ (katello_errata_install, katello_errata_install_by_search)'
labels = [labels, new_labels].map { |label| "(#{label})" }.join(' OR ')
select += ',template_invocations.id AS template_invocation_id'
else
select += ',NULL AS template_invocation_id'
end

search = [search_up_to, search_since, search_result, "state = stopped", labels].compact.join(' and ')

tasks = load_resource(klass: ForemanTasks::Task,
tasks = load_resource(klass: ForemanTasks::Task.left_outer_joins(:template_invocation),
permission: 'view_foreman_tasks',
select: select,
preload: [:template_invocation],
Comment on lines +250 to +252
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I wonder if we should have done a left join in the original fix as well.

search: search)
only_host_ids = ::Host.search_for(host_filter).pluck(:id) if host_filter

Expand Down Expand Up @@ -374,7 +370,7 @@ def errata_ids_from_template_invocation(task, task_input)
found = script.lines.find { |line| line.start_with? '# RESOLVED_ERRATA_IDS=' } || ''
(found.chomp.split('=', 2).last || '').split(',')
else
TemplateInvocationInputValue.joins(:template_input).where("template_invocation_id = ? AND template_inputs.name = ?", task.template_invocation_id, 'errata')
TemplateInvocationInputValue.joins(:template_input).where("template_invocation_id = ? AND template_inputs.name = ?", task.template_invocation.id, 'errata')
.first.value.split(',')
end
end
Expand Down
Loading