Skip to content

Commit

Permalink
State action in special pkg removal report msgs
Browse files Browse the repository at this point in the history
Customers have been confused when seeing the messages, not knowing what
should they do.
  • Loading branch information
bocekm committed Jul 10, 2024
1 parent 52054d3 commit c6fb81a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 45 deletions.
26 changes: 19 additions & 7 deletions convert2rhel/actions/pre_ponr_changes/handle_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,21 @@ 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: %s" % ", ".join(pkgs_not_removed)
message = "The following packages cannot be removed: %s" % ", ".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",
diagnosis=message,
title="Special packages cannot be removed",
description=message,
diagnosis=(
"The packages 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=(
"We do a conversion dry-run (yum transaction validation) later on as part of the pre-conversion"
" analysis. If the dry-run fails, try removing the packages listed above manually."
),
)

if pkgs_removed:
Expand All @@ -163,11 +170,16 @@ def run(self):
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Special packages to be removed",
description=(
description=message,
diagnosis=(
"We have identified installed packages that match a pre-defined list of packages that are"
" to be removed during the conversion"
" to be removed during the conversion. This list includes packages that are known to cause"
" a conversion failure."
),
remediations=(
"No action required. This is just to inform you that the packages won't be installed after"
"the conversion."
),
diagnosis=message,
)

super(RemoveSpecialPackages, self).run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,21 @@ 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="Special 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 to be removed during the conversion. This list includes packages that are known to cause"
" a conversion failure.",
remediations="No action required. This is just to inform you that the packages won't be installed"
" afterthe conversion.",
variables={},
)
)
}
monkeypatch.setattr(
pkghandler, "get_packages_to_remove", GetPackagesToRemoveMocked(return_value=pkgs_to_remove)
)
Expand All @@ -199,31 +200,32 @@ 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="Special packages cannot be removed",
description="The following packages cannot be removed: gpg-pubkey-1.0.0-1.x86_64, pkg1-None-None.None,"
" pkg2-None-None.None",
diagnosis="The packages 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="We do a conversion dry-run (yum transaction validation) later on as part of the"
" pre-conversion analysis. If the dry-run fails, try removing the packages listed above manually.",
variables={},
),
actions.ActionMessage(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
title="Special 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 to be removed during the conversion. This list includes packages that are known to cause"
" a conversion failure.",
remediations="No action required. This is just to inform you that the packages won't be installed"
" afterthe conversion.",
variables={},
),
}
monkeypatch.setattr(
pkghandler, "get_packages_to_remove", GetPackagesToRemoveMocked(pkg_selection="fingerprints")
)
Expand Down

0 comments on commit c6fb81a

Please sign in to comment.