Skip to content
Open
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
6 changes: 4 additions & 2 deletions src/core/src/package_managers/YumPackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,10 @@ def try_mitigate_issues_if_any(self, command, code, out, raise_on_exception=True
self.log_error_mitigation_failure(out, raise_on_exception)
return code, out

if "Error" in out or "Errno" in out:

# Strip the benign "perl-Errno" package token so its "Errno" substring is not misread as an error marker,
# while still detecting any genuine errors present elsewhere in the output.
out_without_perl_errno = out.replace("perl-Errno", "")
if "Error" in out_without_perl_errno or "Errno" in out_without_perl_errno:
# Preemptively exit the retry loop if the same error string is repeating in the call stack.
# This implies that self.check_known_issues_and_attempt_fix may have failed to mitigate the error.
if out in seen_errors:
Expand Down
29 changes: 29 additions & 0 deletions src/core/tests/Test_YumPackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,35 @@ def test_auto_issue_mitigation_when_retries_are_exhausted_raise_exception_disabl
self.assertEqual(out, expected_out)
self.assertTrue(code >= 0)

def test_auto_issue_mitigation_skips_perl_errno_false_positive(self):
# "perl-Errno" contains the substring "Errno" but is not an actual error, so no mitigation is triggered and the output is returned unchanged.
expected_out = "Installing: perl-Errno-1.28-422.el8.x86_64"

package_manager = self.container.get('package_manager')
self.assertTrue(package_manager)

code, out = package_manager.try_mitigate_issues_if_any('testcmd', 0, expected_out)

self.assertEqual(out, expected_out)
self.assertEqual(code, 0)
Comment thread
Copilot marked this conversation as resolved.

def test_auto_issue_mitigation_detects_real_error_alongside_perl_errno(self):
# A benign "perl-Errno" package line must not mask a genuine error in the same output
download_metadata_error = "Error: Failed to download metadata for repo 'rhui-rhel-8-for-x86_64-baseos-rhui-rpms': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried"
out_with_perl_errno = "Installing: perl-Errno-1.28-422.el8.x86_64. " + download_metadata_error
self.runtime.set_legacy_test_type('IssueMitigationRetryExitAfterMultipleAttempts')

package_manager = self.container.get('package_manager')
self.assertTrue(package_manager)

captured_output, original_stdout = self.__capture_std_io()
code, out = package_manager.try_mitigate_issues_if_any('testcmd', 0, out_with_perl_errno, raise_on_exception = False)
sys.stdout = original_stdout

# The genuine error entered the mitigation path and was matched against the known errors list.
self.__assert_std_io(captured_output, expected_output="[YPM] Found a match within known errors list, attempting a fix...")
self.assertGreaterEqual(code, 0)

def test_disable_auto_os_updates_with_uninstalled_services(self):
# no services are installed on the machine. expected o/p: function will complete successfully. Backup file will be created with default values, no auto OS update configuration settings will be updated as there are none
self.runtime.set_legacy_test_type('SadPath')
Expand Down
Loading