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

[RHELC-1635] State action in special pkg removal report msgs #1297

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
23 changes: 16 additions & 7 deletions convert2rhel/actions/pre_ponr_changes/handle_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,22 @@ def run(self):
# shows which packages were not removed, if false, all packages were removed
pkgs_not_removed = sorted(frozenset(pkghandler.get_pkg_nevras(all_pkgs)).difference(pkgs_removed))
if pkgs_not_removed:
message = "The following packages were not removed: {}".format(", ".join(pkgs_not_removed))
message = "The following packages cannot be removed: {}".format(", ".join(pkgs_not_removed))
logger.warning(message)
self.add_message(
level="WARNING",
id="SPECIAL_PACKAGES_NOT_REMOVED",
title="Special packages not removed",
description="Special packages which could not be removed",
title="Some packages cannot be removed",
diagnosis=message,
description=(
"The packages in diagnosis match a pre-defined list of packages that are to be removed during the"
" conversion. This list includes packages that are known to cause a conversion failure."
),
remediations=(
"Remove the packages manually before running convert2rhel again:\n" "yum remove -y {}".format(
" ".join(pkgs_not_removed)
)
),
)

if pkgs_removed:
Expand All @@ -171,12 +179,13 @@ def run(self):
self.add_message(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Special packages to be removed",
description=(
title="Packages to be removed",
description=message,
diagnosis=(
"We have identified installed packages that match a pre-defined list of packages that are"
" to be removed during the conversion"
" known to cause a conversion failure."
),
diagnosis=message,
remediations="Check that the system runs correctly without the packages after the conversion.",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,19 @@ def test_run_no_packages_to_remove(self, monkeypatch, remove_special_packages_in
def test_run_all_removed(self, monkeypatch, remove_special_packages_instance):
pkgs_to_remove = [get_centos_logos_pkg_object()]
pkgs_removed = ["centos-logos-70.0.6-3.el7.centos.noarch"]
expected = set(
(
actions.ActionMessage(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Special packages to be removed",
description="We have identified installed packages that match a pre-defined list of packages that are"
" to be removed during the conversion",
diagnosis="The following packages will be removed during the conversion: centos-logos-70.0.6-3.el7.centos.noarch",
remediations=None,
variables={},
),
expected = {
actions.ActionMessage(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Packages to be removed",
description="The following packages will be removed during the conversion:"
" centos-logos-70.0.6-3.el7.centos.noarch",
diagnosis="We have identified installed packages that match a pre-defined list of packages that"
" are known to cause a conversion failure.",
remediations="Check that the system runs correctly without the packages after the conversion.",
variables={},
)
)
}
monkeypatch.setattr(
pkghandler, "get_packages_to_remove", GetPackagesToRemoveMocked(return_value=pkgs_to_remove)
)
Expand All @@ -206,31 +205,30 @@ def test_run_all_removed(self, monkeypatch, remove_special_packages_instance):
@centos8
def test_run_packages_not_removed(self, pretend_os, monkeypatch, remove_special_packages_instance):
pkgs_removed = ["kernel-core"]
expected = set(
(
actions.ActionMessage(
level="WARNING",
id="SPECIAL_PACKAGES_NOT_REMOVED",
title="Special packages not removed",
description="Special packages which could not be removed",
diagnosis="The following packages were not removed: gpg-pubkey-1.0.0-1.x86_64, pkg1-None-None.None, pkg2-None-None.None",
remediations=None,
variables={},
),
actions.ActionMessage(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Special packages to be removed",
description=(
"We have identified installed packages that match a pre-defined list of packages that are"
" to be removed during the conversion"
),
diagnosis="The following packages will be removed during the conversion: kernel-core",
remediations=None,
variables={},
),
)
)
expected = {
actions.ActionMessage(
level="WARNING",
id="SPECIAL_PACKAGES_NOT_REMOVED",
title="Some packages cannot be removed",
description="The packages in diagnosis match a pre-defined list of packages that are to be removed"
" during the conversion. This list includes packages that are known to cause a conversion failure.",
diagnosis="The following packages cannot be removed: gpg-pubkey-1.0.0-1.x86_64, pkg1-None-None.None,"
" pkg2-None-None.None",
remediations="Remove the packages manually before running convert2rhel again:\n"
"yum remove -y gpg-pubkey-1.0.0-1.x86_64 pkg1-None-None.None pkg2-None-None.None",
variables={},
),
actions.ActionMessage(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Packages to be removed",
description="The following packages will be removed during the conversion: kernel-core",
diagnosis="We have identified installed packages that match a pre-defined list of packages that"
" are known to cause a conversion failure.",
remediations="Check that the system runs correctly without the packages after the conversion.",
variables={},
),
}
monkeypatch.setattr(pkghandler, "get_packages_to_remove", GetPackagesToRemoveMocked(pkg_selection="key_ids"))
monkeypatch.setattr(
handle_packages,
Expand Down
Loading