Description of problem: "foreman-maintain health check --label check-hotfix-installed" is failing with error "undefined method `[]' for nil:NilClass" Version-Release number of selected component (if applicable): Satellite 7.0 Rhel 8.5 How reproducible: Always Steps to Reproduce: 1. Have a fresh Satellite on RHEL 8.5 2. Run foreman-maintain health check --label check-hotfix-installed 3. Actual results: check fails with error "undefined method `[]' for nil:NilClass" Expected results: check should pass Additional info:
Thanks! Can you please try the following patch? diff --git definitions/checks/check_hotfix_installed.rb definitions/checks/check_hotfix_installed.rb index 3f025fc..1873540 100644 --- definitions/checks/check_hotfix_installed.rb +++ definitions/checks/check_hotfix_installed.rb @@ -46,7 +46,7 @@ class Checks::CheckHotfixInstalled < ForemanMaintain::Check def installed_packages packages = [] repoquery_cmd = execute!('which repoquery') - IO.popen([repoquery_cmd, '-a', '--installed', '--qf', '%{ui_from_repo} %{nvra}']) do |io| + IO.popen([repoquery_cmd, '-a', '--installed', '--qf', '%{ui_from_repo} %{name}-%{evr}.%{arch}']) do |io| io.each do |line| repo, pkg = line.chomp.split packages << pkg if /satellite|rhscl/ =~ repo[1..-1].downcase /usr/share/gems/gems/foreman_maintain-1.0.1/definitions/checks/check_hotfix_installed.rb is the file in question on your install
Created redmine issue https://projects.theforeman.org/issues/34393 from this bug
Thanks, after talking with Amit, this needs a bit more safeguarding: diff --git a/definitions/checks/check_hotfix_installed.rb b/definitions/checks/check_hotfix_installed.rb index 3f025fcd..8d9cb471 100644 --- a/definitions/checks/check_hotfix_installed.rb +++ b/definitions/checks/check_hotfix_installed.rb @@ -46,9 +46,11 @@ def modified_files(package) def installed_packages packages = [] repoquery_cmd = execute!('which repoquery') - IO.popen([repoquery_cmd, '-a', '--installed', '--qf', '%{ui_from_repo} %{nvra}']) do |io| + query_format = '%{ui_from_repo} %{name}-%{evr}.%{arch}' + IO.popen([repoquery_cmd, '-a', '--installed', '--qf', query_format]) do |io| io.each do |line| repo, pkg = line.chomp.split + next if repo.nil? || pkg.nil? packages << pkg if /satellite|rhscl/ =~ repo[1..-1].downcase end end (the next if part is new, the other is just differently formatted compared to the version I posted above)
That worked! # foreman-maintain health check --label check-hotfix-installed Running preparation steps required to run the next scenarios ================================================================================ Check whether system has any non Red Hat repositories (e.g.: EPEL) enabled: - Checking repositories enabled on the system [OK] -------------------------------------------------------------------------------- Running ForemanMaintain::Scenario::FilteredScenario ================================================================================ Check to verify if any hotfix installed on system: - Checking for presence of hotfix(es). It may take some time to verify. [OK] --------------------------------------------------------------------------------
Awesome, thanks for the quick feedback!
Upstream bug assigned to egolov
Verified. Tested on Satellite 7.0 Snap 9.0 RHEL 8.5 Steps followed: 1. Have a fresh Satellite on RHEL 8.5 2. Run foreman-maintain health check --label check-hotfix-installed Observation: health check passes without any error as expected.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:5498