Skip to content

Commit

Permalink
[RHELC-1759] Remove zero value report messages (#1436)
Browse files Browse the repository at this point in the history
* Remove unnecessary analysis messages

The "SKIP" post-conversion messages give zero value to the user.
The "OUTDATED_CONVERT2RHEL_VERSION" pre-conversion message was for RHEL
6 only which we do not allow converting anymore.
  • Loading branch information
bocekm authored Dec 3, 2024
1 parent cce2401 commit dbcd745
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 223 deletions.
9 changes: 3 additions & 6 deletions convert2rhel/actions/conversion/lock_releasever.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ def run(self):
# rhsm is used, otherwise, there's no need to lock the releasever as the subscription-manager won't be
# available.
if not system_info.eus_system or tool_opts.no_rhsm:
loggerinst.info("Skipping locking RHEL repositories to a specific EUS minor version.")
self.add_message(
id="SKIPPED_LOCK_RELEASEVER_IN_RHEL_REPOSITORIES",
level="INFO",
title="Skipped releasever lock",
description="Releasever lock is needed only when converting to RHEL EUS using RHSM.",
loggerinst.info(
"Skipping locking RHEL repositories. Releasever lock is needed only when converting to"
"RHEL EUS using RHSM."
)
return
loggerinst.info(
Expand Down
6 changes: 0 additions & 6 deletions convert2rhel/actions/conversion/preserve_only_rhel_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ def run(self):
return

loggerinst.info("RHEL kernel has been verified to be on the system.")
self.add_message(
level="INFO",
id="RHEL_KERNEL_INSTALL_VERIFIED",
title="RHEL kernel install verified",
description="The RHEL kernel has been verified to be on the system.",
)


class FixInvalidGrub2Entries(actions.Action):
Expand Down
22 changes: 1 addition & 21 deletions convert2rhel/actions/post_conversion/hostmetering.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,12 @@ def run(self):

if system_info.version.major != 7 and tool_opts.configure_host_metering == "auto":
logger.info("Did not perform host metering configuration. Only supported for RHEL 7.")
self.add_message(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration.",
description="Host metering is supportted only for RHEL 7.",
)
return False

is_hyperscaler = self.is_running_on_hyperscaler()

if not is_hyperscaler and tool_opts.configure_host_metering == "auto":
logger.info("Did not perform host-metering configuration.")
self.add_message(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration as not needed.",
description="Host metering is not needed on the system.",
)
return False

logger.info("Installing host-metering packages.")
Expand Down Expand Up @@ -138,15 +126,7 @@ def _check_host_metering_configuration(self):
:rtype: bool
"""
if tool_opts.configure_host_metering is None:
logger.debug("Configuration of host metering has not been enabled. Skipping it.")
self.add_message(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration.",
description="Configuration of host metering has been skipped.",
diagnosis="We haven't detected 'configure_host_metering' in the convert2rhel.ini config file nor"
" the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.",
)
logger.debug("You have not enabled configuration of host metering. Skipping it.")
return False

if tool_opts.configure_host_metering not in ("force", "auto"):
Expand Down
45 changes: 12 additions & 33 deletions convert2rhel/actions/system_checks/convert2rhel_latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,42 +192,21 @@ def run(self):
diagnosis=diagnosis,
)
else:
if int(system_info.version.major) <= 6:
logger.warning(
self.set_result(
level="OVERRIDABLE",
id="OUT_OF_DATE",
title="Outdated convert2rhel version detected",
description="An outdated convert2rhel version has been detected",
diagnosis=(
"You are currently running {} and the latest version of convert2rhel is {}.\n"
"We encourage you to update to the latest version.".format(
"Only the latest version is supported for conversion.".format(
formatted_convert2rhel_version, formatted_available_version
)
)
self.add_message(
level="WARNING",
id="OUTDATED_CONVERT2RHEL_VERSION",
title="Outdated convert2rhel version detected",
description="An outdated convert2rhel version has been detected",
diagnosis=(
"You are currently running {} and the latest version of convert2rhel is {}.\n"
"We encourage you to update to the latest version.".format(
formatted_convert2rhel_version, formatted_available_version
)
),
)

else:
self.set_result(
level="OVERRIDABLE",
id="OUT_OF_DATE",
title="Outdated convert2rhel version detected",
description="An outdated convert2rhel version has been detected",
diagnosis=(
"You are currently running {} and the latest version of convert2rhel is {}.\n"
"Only the latest version is supported for conversion.".format(
formatted_convert2rhel_version, formatted_available_version
)
),
remediations="If you want to disregard this check, set the allow_older_version inhibitor"
" override in the /etc/convert2rhel.ini config file to true.",
)
return
),
remediations="If you want to disregard this check, set the allow_older_version inhibitor"
" override in the /etc/convert2rhel.ini config file to true.",
)
return

logger.info("Latest available convert2rhel version is installed.")

Expand Down
19 changes: 3 additions & 16 deletions convert2rhel/unit_tests/actions/conversion/lock_releasever_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import pytest
import six

from convert2rhel import actions, utils
from convert2rhel import utils
from convert2rhel.actions.conversion import lock_releasever
from convert2rhel.systeminfo import Version, system_info
from convert2rhel.unit_tests import RunSubprocessMocked
Expand Down Expand Up @@ -74,18 +74,5 @@ def test_lock_releasever_in_rhel_repositories(

def test_lock_releasever_in_rhel_repositories_not_eus(lock_releasever_in_rhel_repositories_instance, caplog):
lock_releasever_in_rhel_repositories_instance.run()
expected = set(
(
actions.ActionMessage(
level="INFO",
id="SKIPPED_LOCK_RELEASEVER_IN_RHEL_REPOSITORIES",
title="Skipped releasever lock",
description="Releasever lock is needed only when converting to RHEL EUS using RHSM.",
diagnosis=None,
remediations=None,
),
)
)
assert "Skipping locking RHEL repositories to a specific EUS minor version." in caplog.records[-1].message
assert expected.issuperset(lock_releasever_in_rhel_repositories_instance.messages)
assert expected.issubset(lock_releasever_in_rhel_repositories_instance.messages)

assert "Skipping locking RHEL repositories." in caplog.records[-1].message
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,15 @@ def test_install_rhel_kernel(

assert handle_no_newer_rhel_kernel_available.call_count == no_newer_kernel_call

def test_verify_rhel_kernel_installed(self, monkeypatch, install_rhel_kernel_instance):
def test_verify_rhel_kernel_installed(self, monkeypatch, install_rhel_kernel_instance, caplog):
monkeypatch.setattr(
pkghandler,
"get_installed_pkgs_by_key_id",
GetInstalledPkgsByKeyIdMocked(return_value=[create_pkg_information(name="kernel")]),
)
install_rhel_kernel_instance.run()
expected = set(
(
actions.ActionMessage(
level="INFO",
id="RHEL_KERNEL_INSTALL_VERIFIED",
title="RHEL kernel install verified",
description="The RHEL kernel has been verified to be on the system.",
diagnosis=None,
remediations=None,
),
)
)
assert expected.issuperset(install_rhel_kernel_instance.messages)
assert expected.issubset(install_rhel_kernel_instance.messages)

assert "RHEL kernel has been verified to be on the system." in caplog.text

def test_verify_rhel_kernel_installed_not_installed(self, monkeypatch, install_rhel_kernel_instance):
monkeypatch.setattr(pkghandler, "get_installed_pkgs_by_key_id", mock.Mock(return_value=[]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,7 @@ def test_configure_host_metering(
(None, 0),
("", ""),
False,
set(
(
actions.ActionMessage(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration.",
description="Host metering is supportted only for RHEL 7.",
),
),
),
None,
actions.ActionResult(level="SUCCESS", id="SUCCESS"),
),
(
Expand Down Expand Up @@ -252,16 +243,7 @@ def test_configure_host_metering(
(None, 0),
("", ""),
None,
set(
(
actions.ActionMessage(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration as not needed.",
description="Host metering is not needed on the system.",
),
),
),
None,
actions.ActionResult(level="SUCCESS", id="SUCCESS"),
),
(
Expand Down Expand Up @@ -375,28 +357,18 @@ def test_configure_host_metering_messages_and_results(
monkeypatch.setattr(toolopts, "tool_opts", global_tool_opts)
hostmetering_instance.run()

assert action_message.issuperset(hostmetering_instance.messages)
assert action_message.issubset(hostmetering_instance.messages)
if action_message:
assert action_message.issuperset(hostmetering_instance.messages)
assert action_message.issubset(hostmetering_instance.messages)
assert action_result == hostmetering_instance.result


def test_configure_host_metering_no_env_var(monkeypatch, hostmetering_instance, global_tool_opts):
expected = {
actions.ActionMessage(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration.",
description="Configuration of host metering has been skipped.",
diagnosis="We haven't detected 'configure_host_metering' in the convert2rhel.ini config file nor"
" the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.",
)
}
def test_configure_host_metering_no_env_var(monkeypatch, hostmetering_instance, global_tool_opts, caplog):
monkeypatch.setattr(hostmetering, "tool_opts", global_tool_opts)

hostmetering_instance.run()

assert expected.issuperset(hostmetering_instance.messages)
assert expected.issubset(hostmetering_instance.messages)
assert "You have not enabled configuration of host metering. Skipping it." in caplog.records[-1].message
assert actions.ActionResult(level="SUCCESS", id="SUCCESS") == hostmetering_instance.result


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,97 +165,6 @@ def test_convert2rhel_latest_outdated_version_inhibitor(
" override in the /etc/convert2rhel.ini config file to true.",
)

@pytest.mark.parametrize(
("prepare_convert2rhel_latest_action",),
(
[
{
"local_version": "0.21",
"package_version": "C2R convert2rhel-0:0.22-1.el7.noarch",
"package_version_repoquery": "C2R convert2rhel-0:0.22-1.el7.noarch",
"package_version_qf": "C2R convert2rhel-0:0.21-1.el7.noarch",
"package_version_V": " ",
"pmajor": "6",
"running_version": "0.21",
"latest_version": "0.22",
}
],
[
{
"local_version": "0.21",
"package_version": "C2R convert2rhel-0:1.10-1.el7.noarch",
"package_version_repoquery": "C2R convert2rhel-0:1.10-1.el7.noarch",
"package_version_qf": "C2R convert2rhel-0:0.21-1.el7.noarch",
"package_version_V": " ",
"pmajor": "6",
"running_version": "0.21",
"latest_version": "1.10",
}
],
[
{
"local_version": "1.21.0",
"package_version": "C2R convert2rhel-0:1.21.1-1.el7.noarch",
"package_version_repoquery": "C2R convert2rhel-0:1.21.1-1.el7.noarch",
"package_version_qf": "C2R convert2rhel-0:1.21.0-1.el7.noarch",
"package_version_V": " ",
"pmajor": "6",
"running_version": "1.21.0",
"latest_version": "1.21.1",
}
],
[
{
"local_version": "1.21",
"package_version": "C2R convert2rhel-0:1.21.1-1.el7.noarch",
"package_version_repoquery": "C2R convert2rhel-0:1.21.1-1.el7.noarch",
"package_version_qf": "C2R convert2rhel-0:1.21-1.el7.noarch",
"package_version_V": 0,
"pmajor": "6",
"running_version": "1.21",
"latest_version": "1.21.1",
}
],
[
{
"local_version": "1.21.1",
"package_version": "C2R convert2rhel-0:0.22-1.el7.noarch",
"package_version_repoquery": "C2R convert2rhel-0:1.22-1.el7.noarch",
"package_version_qf": "C2R convert2rhel-0:1.21.1-1.el7.noarch",
"package_version_V": 0,
"pmajor": "6",
"running_version": "1.21.1",
"latest_version": "1.22",
}
],
),
indirect=True,
)
def test_convert2rhel_latest_outdated_version_warning(
self, convert2rhel_latest_action_instance, prepare_convert2rhel_latest_action, monkeypatch, global_tool_opts
):
"""When runnnig on an older unsupported major version, we issue just a warning instead of an inhibitor."""
monkeypatch.setattr(convert2rhel_latest, "tool_opts", global_tool_opts)
convert2rhel_latest_action_instance.run()

running_version, latest_version = prepare_convert2rhel_latest_action

expected = {
actions.ActionMessage(
level="WARNING",
id="OUTDATED_CONVERT2RHEL_VERSION",
title="Outdated convert2rhel version detected",
description="An outdated convert2rhel version has been detected",
diagnosis=(
"You are currently running {} and the latest version of convert2rhel is {}.\n"
"We encourage you to update to the latest version.".format(running_version, latest_version)
),
remediations=None,
)
}
assert expected.issuperset(convert2rhel_latest_action_instance.messages)
assert expected.issubset(convert2rhel_latest_action_instance.messages)

@pytest.mark.parametrize(
("prepare_convert2rhel_latest_action",),
(
Expand Down

0 comments on commit dbcd745

Please sign in to comment.