Skip to content

Commit

Permalink
[RHELC-1089] Revert overridable result in package handling check (oam…
Browse files Browse the repository at this point in the history
  • Loading branch information
pr-watson authored Nov 29, 2023
1 parent 23aadbf commit a739cd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 68 deletions.
29 changes: 1 addition & 28 deletions convert2rhel/actions/pre_ponr_changes/handle_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,19 @@ def run(self):

logger.task("Convert: List third-party packages")
third_party_pkgs = pkghandler.get_third_party_pkgs()
third_party_package_skip = os.environ.get("CONVERT2RHEL_THIRD_PARTY_PACKAGE_CHECK_SKIP", None)
if third_party_pkgs:
pkg_list = pkghandler.format_pkg_info(sorted(third_party_pkgs, key=self.extract_packages))
warning_message = (
"Only packages signed by %s are to be"
" replaced. Red Hat support won't be provided"
" for the following third party packages:\n" % system_info.name
)
if not third_party_package_skip:
logger.warning(warning_message)
logger.info(pkg_list)
self.set_result(
level="OVERRIDABLE",
id="THIRD_PARTY_PACKAGE_DETECTED",
title="Third party packages detected",
description="Third party packages will not be replaced during the conversion.",
diagnosis=warning_message + ", ".join(pkghandler.get_pkg_nevras(third_party_pkgs)),
remediation="If you wish to ignore this message, set the environment variable "
"'CONVERT2RHEL_THIRD_PARTY_PACKAGE_CHECK_SKIP' to 1.",
)
return

skip_message = (
"Detected 'CONVERT2RHEL_THIRD_PARTY_PACKAGE_CHECK_SKIP' environment variable, we will skip "
"the third party package check.\n"
"Beware, this could leave your system in a broken state."
)
logger.warning(skip_message)
self.add_message(
level="WARNING",
id="SKIP_THIRD_PARTY_PACKAGE_CHECK",
title="Skip third party package check",
description=skip_message,
)

logger.warning(warning_message)
logger.info(pkg_list)
self.add_message(
level="WARNING",
id="THIRD_PARTY_PACKAGE_DETECTED_MESSAGE",
id="THIRD_PARTY_PACKAGE_DETECTED",
title="Third party packages detected",
description="Third party packages will not be replaced during the conversion.",
diagnosis=warning_message + ", ".join(pkghandler.get_pkg_nevras(third_party_pkgs)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,57 +62,20 @@ def test_list_third_party_packages(pretend_os, list_third_party_packages_instanc
" for the following third party packages:\npkg1-None-None.None, pkg2-None-None.None, gpg-pubkey-1.0.0-1.x86_64"
)
list_third_party_packages_instance.run()
unit_tests.assert_actions_result(
list_third_party_packages_instance,
level="OVERRIDABLE",
id="THIRD_PARTY_PACKAGE_DETECTED",
title="Third party packages detected",
description="Third party packages will not be replaced during the conversion.",
diagnosis=diagnosis,
remediation="If you wish to ignore this message, set the environment variable "
"'CONVERT2RHEL_THIRD_PARTY_PACKAGE_CHECK_SKIP' to 1.",
)

assert len(pkghandler.format_pkg_info.call_args[0][0]) == 3


@centos7
def test_list_third_party_packages_skip(list_third_party_packages_instance, pretend_os, monkeypatch, caplog):
monkeypatch.setattr(pkghandler, "get_third_party_pkgs", GetThirdPartyPkgsMocked(pkg_selection="fingerprints"))
monkeypatch.setattr(pkghandler, "format_pkg_info", FormatPkgInfoMocked(return_value=["shim", "ruby", "pytest"]))
monkeypatch.setattr(
os,
"environ",
{"CONVERT2RHEL_THIRD_PARTY_PACKAGE_CHECK_SKIP": 1},
)
expected = set(
(
actions.ActionMessage(
level="WARNING",
id="THIRD_PARTY_PACKAGE_DETECTED_MESSAGE",
id="THIRD_PARTY_PACKAGE_DETECTED",
title="Third party packages detected",
description="Third party packages will not be replaced during the conversion.",
diagnosis=(
"Only packages signed by CentOS Linux are to be replaced. Red Hat support won't be provided"
" for the following third party packages:\npkg1-None-None.None, pkg2-None-None.None, gpg-pubkey-1.0.0-1.x86_64"
),
),
actions.ActionMessage(
level="WARNING",
id="SKIP_THIRD_PARTY_PACKAGE_CHECK",
title="Skip third party package check",
description=(
"Detected 'CONVERT2RHEL_THIRD_PARTY_PACKAGE_CHECK_SKIP' environment variable, we will skip "
"the third party package check.\n"
"Beware, this could leave your system in a broken state."
),
diagnosis=diagnosis,
),
)
)
list_third_party_packages_instance.run()
assert expected.issuperset(list_third_party_packages_instance.messages)
assert expected.issubset(list_third_party_packages_instance.messages)
assert list_third_party_packages_instance.result.level == actions.STATUS_CODE["SUCCESS"]
assert len(pkghandler.format_pkg_info.call_args[0][0]) == 3


@pytest.fixture
Expand Down

0 comments on commit a739cd4

Please sign in to comment.