From 913b7093aad872ab4fd632505718e0990c812323 Mon Sep 17 00:00:00 2001 From: Michal Bocek Date: Wed, 20 Nov 2024 16:55:11 +0100 Subject: [PATCH] Tell users to use config ini instead of env vars Env vars have been deprecated in favor of the ini config file (e.g. /etc/convert2rhel.ini). We should be telling users to use the config file instead of the deprecated env vars. --- .../actions/post_conversion/hostmetering.py | 74 ++++----- .../modified_rpm_files_diff.py | 4 +- .../actions/post_conversion/remove_tmp_dir.py | 2 +- .../actions/pre_ponr_changes/backup_system.py | 3 +- .../pre_ponr_changes/handle_packages.py | 2 +- .../pre_ponr_changes/kernel_modules.py | 16 +- .../check_firewalld_availability.py | 2 +- .../system_checks/convert2rhel_latest.py | 5 +- .../system_checks/is_loaded_kernel_latest.py | 25 ++- .../actions/system_checks/tainted_kmods.py | 14 +- convert2rhel/backup/certs.py | 2 +- convert2rhel/backup/files.py | 2 +- convert2rhel/backup/packages.py | 4 +- convert2rhel/cli.py | 4 +- convert2rhel/logger.py | 4 +- .../pkgmanager/handlers/dnf/__init__.py | 14 +- .../pkgmanager/handlers/yum/__init__.py | 12 +- convert2rhel/subscription.py | 16 +- convert2rhel/toolopts/__init__.py | 4 +- .../post_conversion/hostmetering_test.py | 152 ++++++++---------- .../modified_rpm_files_diff_test.py | 4 +- .../post_conversion/remove_tmp_dir_test.py | 2 +- .../pre_ponr_changes/backup_system_test.py | 10 +- .../pre_ponr_changes/handle_packages_test.py | 2 +- .../pre_ponr_changes/kernel_modules_test.py | 10 +- .../check_firewalld_availability_test.py | 2 +- .../system_checks/convert2rhel_latest_test.py | 8 +- .../is_loaded_kernel_latest_test.py | 34 ++-- .../system_checks/tainted_kmods_test.py | 71 ++++---- convert2rhel/unit_tests/cli_test.py | 5 +- .../pkgmanager/handlers/dnf/dnf_test.py | 10 +- .../pkgmanager/handlers/yum/yum_test.py | 6 +- .../unit_tests/toolopts/toolopts_test.py | 4 +- convert2rhel/unit_tests/utils/utils_test.py | 6 +- convert2rhel/utils/__init__.py | 7 +- 35 files changed, 258 insertions(+), 284 deletions(-) diff --git a/convert2rhel/actions/post_conversion/hostmetering.py b/convert2rhel/actions/post_conversion/hostmetering.py index 4602b6a175..53f2537b3c 100644 --- a/convert2rhel/actions/post_conversion/hostmetering.py +++ b/convert2rhel/actions/post_conversion/hostmetering.py @@ -28,20 +28,16 @@ class ConfigureHostMetering(actions.Action): - """Configure host metering on a machine if it's needed. - - env_var: str - Content of CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable. - """ + """Configure host metering on a machine if it's needed.""" id = "CONFIGURE_HOST_METERING_IF_NEEDED" def run(self): """ - Decide whether to install, enable and start host-metering on the system based on the - CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable. + Decide whether to install, enable and start host-metering on the system based on the setting of + 'configure_host_metering' in /etc/convert2rhel.ini. - Behavior can be controlled CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: + The behavior can be controlled via the 'configure_host_metering' as follows: - "auto": host-metering will be configured based on the above conditions - "force": forces configuration of host-metering (e.g., even if not running on a hyperscaler) - any other value: Will be ignored and host metering will not be configured. @@ -53,16 +49,16 @@ def run(self): super(ConfigureHostMetering, self).run() warn_deprecated_env("CONVERT2RHEL_CONFIGURE_HOST_METERING") - if not self._check_env_var(): + if not self._check_host_metering_configuration(): return False 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.", + id="CONFIGURE_HOST_METERING_SKIP_ONLY_RHEL_7", + title="Did not perform host metering configuration", + description="Host metering is supported only for RHEL 7.", ) return False @@ -72,9 +68,9 @@ def run(self): 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.", + id="CONFIGURE_HOST_METERING_SKIP_NOT_HYPERSCALER", + title="Did not perform host metering configuration", + description="Host metering is not needed on the system as it is not running on a hyperscaler.", ) return False @@ -85,8 +81,8 @@ def run(self): self.add_message( level="WARNING", id="INSTALL_HOST_METERING_FAILURE", - title="Failed to install host metering package.", - description="When installing host metering package an error occurred meaning we can't" + title="Failed to install the host-metering package", + description="When installing the host-metering package an error occurred meaning we can't" " enable host metering on the system.", diagnosis="`yum install host-metering` command returned {ret_install} with message {output}".format( ret_install=ret_install, output=output @@ -105,9 +101,9 @@ def run(self): self.add_message( level="WARNING", id="CONFIGURE_HOST_METERING_FAILURE", - title="Failed to enable and start host metering service.", + title="Failed to enable and start the host metering service", description="The host metering service failed to start" - " successfully and won't be able to keep track.", + " successfully and won't be able to report on the use of the system for the billing purposes.", diagnosis="Command {command} failed with {error_message}".format( command=command, error_message=error_message ), @@ -125,7 +121,7 @@ def run(self): self.set_result( level="ERROR", id="HOST_METERING_NOT_RUNNING", - title="Host metering service is not running.", + title="Host metering service is not running", description="host-metering.service is not running.", remediations="You can try to start the service manually" " by running following command:\n" @@ -134,52 +130,58 @@ def run(self): return service_running - def _check_env_var(self): - """Check if the env var is set and if it has the right content. If the - content is auto|force, the hostmetering should be configued on the system. + def _check_host_metering_configuration(self): + """Check if host metering has been configured by the user and if the configuration option has the right value. + If the value is auto|force, the host metering should be configured on the system. :return: Return True if the value is equal to auto|force, otherwise False :rtype: bool """ if tool_opts.configure_host_metering is None: - logger.debug("CONVERT2RHEL_CONFIGURE_HOST_METERING was not set. Skipping it.") + 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="CONVERT2RHEL_CONFIGURE_HOST_METERING was not set.", + id="CONFIGURE_HOST_METERING_SKIP_OPTION_NOT_DETECTED", + 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.", ) return False if tool_opts.configure_host_metering not in ("force", "auto"): - logger.debug("Value for environment variable not recognized: {}".format(tool_opts.configure_host_metering)) + logger.debug("Unexpected value of 'configure_host_metering' in convert2rhel.ini or the" + " CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: {}" + .format(tool_opts.configure_host_metering)) self.add_message( level="WARNING", id="UNRECOGNIZED_OPTION_CONFIGURE_HOST_METERING", - title="Unrecognized option in CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", - description="Environment variable {env_var} not recognized.".format( - env_var=tool_opts.configure_host_metering - ), - remediations="Set the option to `auto` value if you want to configure host metering.", + title="Unexpected value of the host metering setting", + diagnosis="Unexpected value of 'configure_host_metering' in convert2rhel.ini or the" + " CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: {}" + .format(tool_opts.configure_host_metering), + description="Host metering will not be configured.", + remediations="Set the option to 'auto' or 'force' if you want to configure host metering.", ) return False if tool_opts.configure_host_metering == "force": logger.warning( - "The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable." + "You've set the host metering setting to 'force'." " Please note that this option is mainly used for testing and will configure host-metering unconditionally. " " For generic usage please use the 'auto' option." ) self.add_message( level="WARNING", id="FORCED_CONFIGURE_HOST_METERING", - title="The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", + title="Configuration of host metering set to 'force'", description="Please note that this option is mainly used for testing and" " will configure host-metering unconditionally." " For generic usage please use the 'auto' option.", ) elif tool_opts.configure_host_metering == "auto": - logger.debug("Automatic detection of host hyperscaler and configuration.") + logger.debug("Configuration of host metering set to 'auto' - host-metering will be enabled based on" + " a detected hyperscaler.") return True diff --git a/convert2rhel/actions/post_conversion/modified_rpm_files_diff.py b/convert2rhel/actions/post_conversion/modified_rpm_files_diff.py index a458817f57..de7891861e 100644 --- a/convert2rhel/actions/post_conversion/modified_rpm_files_diff.py +++ b/convert2rhel/actions/post_conversion/modified_rpm_files_diff.py @@ -46,7 +46,7 @@ def run(self): self.add_message( level="INFO", id="SKIPPED_MODIFIED_RPM_FILES_DIFF", - title="Skipped comparison of 'rpm -Va' output from before and after the conversion.", + title="Skipped comparison of 'rpm -Va' output from before and after the conversion", description="Comparison of 'rpm -Va' output was not performed due to missing output " "of the 'rpm -Va' run before the conversion.", diagnosis="This is caused mainly by using '--no-rpm-va' argument for convert2rhel.", @@ -76,7 +76,7 @@ def run(self): self.add_message( level="INFO", id="FOUND_MODIFIED_RPM_FILES", - title="Modified rpm files from before and after the conversion were found.", + title="Modified rpm files from before and after the conversion were found", description="Comparison of modified rpm files from before and after " "the conversion: \n{}".format( modified_rpm_files_diff ), diff --git a/convert2rhel/actions/post_conversion/remove_tmp_dir.py b/convert2rhel/actions/post_conversion/remove_tmp_dir.py index d89088572b..fa0bc51f71 100644 --- a/convert2rhel/actions/post_conversion/remove_tmp_dir.py +++ b/convert2rhel/actions/post_conversion/remove_tmp_dir.py @@ -61,6 +61,6 @@ def run(self): self.add_message( level="WARNING", id="UNSUCCESSFUL_REMOVE_TMP_DIR", - title="Temporary folder {tmp_dir} wasn't removed.".format(tmp_dir=self.tmp_dir), + title="Temporary folder {tmp_dir} wasn't removed".format(tmp_dir=self.tmp_dir), description=warning_message, ) diff --git a/convert2rhel/actions/pre_ponr_changes/backup_system.py b/convert2rhel/actions/pre_ponr_changes/backup_system.py index 97a63f8730..942ba79e68 100644 --- a/convert2rhel/actions/pre_ponr_changes/backup_system.py +++ b/convert2rhel/actions/pre_ponr_changes/backup_system.py @@ -192,7 +192,8 @@ def _get_changed_package_files(self): except IOError as err: warn_deprecated_env("CONVERT2RHEL_INCOMPLETE_ROLLBACK") if tool_opts.incomplete_rollback: - logger.debug("Skipping backup of the package files. CONVERT2RHEL_INCOMPLETE_ROLLBACK detected.") + logger.debug("You have set the incomplete rollback inhibitor override - skipping backup of" + " the package files.") # Return empty list results in no backup of the files return data else: diff --git a/convert2rhel/actions/pre_ponr_changes/handle_packages.py b/convert2rhel/actions/pre_ponr_changes/handle_packages.py index 717d020e3a..9c0acbcade 100644 --- a/convert2rhel/actions/pre_ponr_changes/handle_packages.py +++ b/convert2rhel/actions/pre_ponr_changes/handle_packages.py @@ -146,7 +146,7 @@ def run(self): self.set_result( level="ERROR", id="SPECIAL_PACKAGE_REMOVAL_FAILED", - title="Failed to remove some packages necessary for the conversion.", + title="Failed to remove some packages necessary for the conversion", description="The cause of this error is unknown, please look at the diagnosis for more information.", diagnosis=str(e), ) diff --git a/convert2rhel/actions/pre_ponr_changes/kernel_modules.py b/convert2rhel/actions/pre_ponr_changes/kernel_modules.py index d99f884ce0..190bf4f2de 100644 --- a/convert2rhel/actions/pre_ponr_changes/kernel_modules.py +++ b/convert2rhel/actions/pre_ponr_changes/kernel_modules.py @@ -247,21 +247,21 @@ def run(self): rhel_supported_kmods = self._get_rhel_supported_kmods() unsupported_kmods = self._get_unsupported_kmods(host_kmods, rhel_supported_kmods) - # Check if we have the environment variable set, if we do, send a + # Check if the user has specified that they allow unavailable kmods and if so, print a # warning and return. warn_deprecated_env("CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS") if tool_opts.allow_unavailable_kmods: logger.warning( - "Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable." - " We will continue the conversion with the following kernel modules unavailable in RHEL:\n" + "You have set the option to allow unavailable kernel modules." + " The conversion will continue with the following kernel modules unavailable in RHEL:\n" "{kmods}\n".format(kmods="\n".join(unsupported_kmods)) ) self.add_message( level="WARNING", id="ALLOW_UNAVAILABLE_KERNEL_MODULES", - title="Did not perform the ensure kernel modules compatibility check", - description="Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable.", - diagnosis="We will continue the conversion with the following kernel modules unavailable in RHEL:\n" + title="Ignoring the check ensuring kernel module availability in RHEL", + diagnosis="You have set the option to allow unavailable kernel modules.", + description="We will continue the conversion with the following kernel modules unavailable in RHEL:\n" "{kmods}\n".format(kmods="\n".join(unsupported_kmods)), ) return @@ -280,8 +280,8 @@ def run(self): "message persists, you can prevent the modules from loading by following {0} and rerun convert2rhel.\n" "Keeping them loaded could cause the system to malfunction after the conversion as they might not work " "properly with the RHEL kernel.\n" - "To circumvent this check and accept the risk you can set environment variable " - "'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS=1'.".format(LINK_PREVENT_KMODS_FROM_LOADING), + "To circumvent this check and accept the risk, set the allow_unavailable_kmods inhibitor override in the" + "/etc/convert2rhel.ini config file to true.".format(LINK_PREVENT_KMODS_FROM_LOADING), ) return diff --git a/convert2rhel/actions/system_checks/check_firewalld_availability.py b/convert2rhel/actions/system_checks/check_firewalld_availability.py index 34dc7b44bd..599c26f0b1 100644 --- a/convert2rhel/actions/system_checks/check_firewalld_availability.py +++ b/convert2rhel/actions/system_checks/check_firewalld_availability.py @@ -102,7 +102,7 @@ def run(self): self.set_result( level="ERROR", id="FIREWALLD_MODULES_CLEANUP_ON_EXIT_CONFIG", - title="Firewalld is set to cleanup modules after exit.", + title="Firewalld is set to cleanup modules after exit", description="Firewalld running on Oracle Linux 8 can lead to a conversion failure.", diagnosis=( "We've detected that firewalld unit is running and that causes iptables and nftables " diff --git a/convert2rhel/actions/system_checks/convert2rhel_latest.py b/convert2rhel/actions/system_checks/convert2rhel_latest.py index e6b4c210a7..72e28e5f54 100644 --- a/convert2rhel/actions/system_checks/convert2rhel_latest.py +++ b/convert2rhel/actions/system_checks/convert2rhel_latest.py @@ -179,7 +179,7 @@ def run(self): if tool_opts.allow_older_version: diagnosis = ( "You are currently running {} and the latest version of convert2rhel is {}.\n" - "'CONVERT2RHEL_ALLOW_OLDER_VERSION' environment variable detected, continuing conversion".format( + "You have set the option to allow older convert2rhel version, continuing conversion".format( formatted_convert2rhel_version, formatted_available_version ) ) @@ -224,7 +224,8 @@ def run(self): formatted_convert2rhel_version, formatted_available_version ) ), - remediations="If you want to disregard this check, then set the environment variable 'CONVERT2RHEL_ALLOW_OLDER_VERSION=1' to continue.", + 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 diff --git a/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py b/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py index 1069029846..66917ca9e9 100644 --- a/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py +++ b/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py @@ -69,20 +69,17 @@ def run(self): warn_deprecated_env("CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK") if tool_opts.skip_kernel_currency_check: logger.warning( - "Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip " - "the {} comparison.\n" - "Beware, this could leave your system in a broken state.".format(package_to_check) + "You have set the option to skip the kernel currency check. We will not be checking if the loaded" + " kernel is of the latest version available.\nBeware, this could leave your system in a broken state." ) self.add_message( level="WARNING", id="UNSUPPORTED_SKIP_KERNEL_CURRENCY_CHECK_DETECTED", title="Did not perform the kernel currency check", - description=( - "Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip " - "the {} comparison.\n" - "Beware, this could leave your system in a broken state.".format(package_to_check) - ), + description="We will not be checking if the loaded kernel is of the latest version available." + "\nBeware, this could leave your system in a broken state.", + diagnosis="You have set the option to skip the kernel currency check." ) return @@ -98,7 +95,7 @@ def run(self): logger.debug("Got the following output: %s", repoquery_output) logger.warning( "Couldn't fetch the list of the most recent kernels available in " - "the repositories. Did not perform the loaded kernel check." + "the repositories. Did not perform the loaded kernel currency check." ) self.add_message( level="WARNING", @@ -106,7 +103,7 @@ def run(self): title="Unable to fetch recent kernels", description=( "Couldn't fetch the list of the most recent kernels available in " - "the repositories. Did not perform the loaded kernel check." + "the repositories. Did not perform the loaded kernel currency check." ), ) return @@ -142,8 +139,8 @@ def run(self): ), remediations=( "Please, check if you have any vendor repositories enabled to proceed with the conversion.\n" - "If you wish to disregard this message, set the environment variable " - "'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1." + "If you wish to disregard this message, set the skip_kernel_currency_check inhibitor override in" + " the /etc/convert2rhel.ini config file to true." ), ) return @@ -184,8 +181,8 @@ def run(self): "To proceed with the conversion, update the kernel version by executing the following step:\n\n" "1. yum install {}-{} -y\n" "2. reboot\n" - "If you wish to ignore this message, set the environment variable " - "'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1.".format(package_to_check, latest_kernel) + "If you wish to ignore this message, set the skip_kernel_currency_check inhibitor override in" + " the /etc/convert2rhel.ini config file to true.".format(package_to_check, latest_kernel) ), ) return diff --git a/convert2rhel/actions/system_checks/tainted_kmods.py b/convert2rhel/actions/system_checks/tainted_kmods.py index a289bdf82e..e1a7cc1ee2 100644 --- a/convert2rhel/actions/system_checks/tainted_kmods.py +++ b/convert2rhel/actions/system_checks/tainted_kmods.py @@ -62,12 +62,12 @@ def run(self): remediations=( "Prevent the modules from loading by following {0}" " and run convert2rhel again to continue with the conversion." - " Although it is not recommended, you can disregard this message by setting the environment variable" - " 'CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP' to 1. Overriding this check can be dangerous" + " Although it is not recommended, you can disregard this message by setting the" + " tainted_kernel_module_check_skip inhibitor override in the /etc/convert2rhel.ini" + " config file to true. Overriding this check can be dangerous" " so it is recommended that you do a system backup beforehand." - " For information on what a tainted kernel module is, please refer to this documentation {1}".format( - LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS - ) + " For information on what a tainted kernel module is, please refer to this documentation {1}" + .format(LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS) ), ) return @@ -76,9 +76,9 @@ def run(self): level="WARNING", id="SKIP_TAINTED_KERNEL_MODULE_CHECK", title="Skip tainted kernel module check", + diagnosis="You have set the option to skip the tainted kernel module check.", description=( - "Detected 'CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP' environment variable, we will skip " - "the tainted kernel module check.\n" + "We will ignore results of the check that makes sure no tainted kernel modules are loaded.\n" "Beware, this could leave your system in a broken state." ), ) diff --git a/convert2rhel/backup/certs.py b/convert2rhel/backup/certs.py index 92b9f409a2..e25a2f1276 100644 --- a/convert2rhel/backup/certs.py +++ b/convert2rhel/backup/certs.py @@ -122,7 +122,7 @@ def enable(self): logger.critical_no_exit("OSError({0}): {1}".format(err.errno, err.strerror)) raise exceptions.CriticalError( id_="FAILED_TO_INSTALL_CERTIFICATE", - title="Failed to install certificate.", + title="Failed to install a certificate", description="convert2rhel was unable to install a required certificate. This certificate allows the pre-conversion analysis to verify that packages are legitimate RHEL packages.", diagnosis="Failed to install certificate {} to {}. Errno: {}, Error: {}".format( self._get_source_cert_path, self._target_cert_dir, err.errno, err.strerror diff --git a/convert2rhel/backup/files.py b/convert2rhel/backup/files.py index 2622817aa8..630efbdbd6 100644 --- a/convert2rhel/backup/files.py +++ b/convert2rhel/backup/files.py @@ -65,7 +65,7 @@ def enable(self): logger.critical_no_exit("Error({}): {}".format(err.errno, err.strerror)) raise exceptions.CriticalError( id_="FAILED_TO_SAVE_FILE_TO_BACKUP_DIR", - title="Failed to copy file to the backup directory.", + title="Failed to copy file to the backup directory", description=( "Copying the current file has failed. This can lead to inconsistency during the rollbacks as " "convert2rhel won't be able to restore the file in case of failures." diff --git a/convert2rhel/backup/packages.py b/convert2rhel/backup/packages.py index 2cbfa31b95..e08c1aa903 100644 --- a/convert2rhel/backup/packages.py +++ b/convert2rhel/backup/packages.py @@ -165,7 +165,7 @@ def _install_local_rpms(self, replace=False, critical=True): logger.critical_no_exit("Error: Couldn't install {} packages.".format(pkgs_as_str)) raise exceptions.CriticalError( id_="FAILED_TO_INSTALL_PACKAGES", - title="Couldn't install packages.", + title="Couldn't install packages", description=( "While attempting to roll back changes, we encountered " "an unexpected failure while attempting to reinstall " @@ -277,7 +277,7 @@ def _enable(self): ) raise exceptions.CriticalError( id_="FAILED_TO_INSTALL_SCHEDULED_PACKAGES", - title="Failed to install scheduled packages.", + title="Failed to install scheduled packages", description="convert2rhel was unable to install scheduled packages.", diagnosis="Failed to install packages {}. Output: {}, Status: {}".format( formatted_pkgs_sequence, output, ret_code diff --git a/convert2rhel/cli.py b/convert2rhel/cli.py index a4e83439ac..2ca3b8bac3 100644 --- a/convert2rhel/cli.py +++ b/convert2rhel/cli.py @@ -133,8 +133,8 @@ def _register_options(self): " stored in log files {} and {}. At the end of the conversion, these logs are compared" " to show you what rpm files have been affected by the conversion." " Cannot be used with analyze subcommand." - " The environment variable CONVERT2RHEL_INCOMPLETE_ROLLBACK" - " needs to be set to 1 to use this argument.".format( + " The incomplete_rollback option needs to be set to true in the /etc/convert2rhel.ini config file to" + " use this argument.".format( utils.rpm.PRE_RPM_VA_LOG_FILENAME, utils.rpm.POST_RPM_VA_LOG_FILENAME ), ) diff --git a/convert2rhel/logger.py b/convert2rhel/logger.py index b9182f928b..442df04eda 100644 --- a/convert2rhel/logger.py +++ b/convert2rhel/logger.py @@ -95,8 +95,8 @@ def flush(self): def shouldFlush(self, record): """ - We should never flush automatically, so we set this to always return false, that way we need to flush manually each time. Which is exactly what we want when it comes to keeping a buffer before we confirm we are - a root user. + We should never flush automatically, so we set this to always return false, that way we need to flush manually + each time. Which is exactly what we want when it comes to keeping a buffer before we confirm we are a root user. :param logging.LogRecord record: The record to log :return bool: Always returns false diff --git a/convert2rhel/pkgmanager/handlers/dnf/__init__.py b/convert2rhel/pkgmanager/handlers/dnf/__init__.py index 1651f3aa3a..5a7d46e32a 100644 --- a/convert2rhel/pkgmanager/handlers/dnf/__init__.py +++ b/convert2rhel/pkgmanager/handlers/dnf/__init__.py @@ -111,7 +111,7 @@ def _enable_repos(self): logger.critical_no_exit("Failed to populate repository metadata.") raise exceptions.CriticalError( id_="FAILED_TO_ENABLE_REPOS", - title="Failed to enable repositories.", + title="Failed to enable repositories", description="We've encountered a failure when accessing repository metadata.", diagnosis="Loading repository metadata failed with error {}.".format(str(e)), ) @@ -191,7 +191,7 @@ def _resolve_dependencies(self): logger.critical_no_exit("Failed to resolve dependencies in the transaction.") raise exceptions.CriticalError( id_="FAILED_TO_RESOLVE_DEPENDENCIES", - title="Failed to resolve dependencies.", + title="Failed to resolve dependencies", description="During package transaction dnf failed to resolve the necessary dependencies needed for a package replacement.", diagnosis="Resolve dependencies failed with error {}.".format(str(e)), ) @@ -204,7 +204,7 @@ def _resolve_dependencies(self): logger.critical_no_exit("Failed to download the transaction packages.") raise exceptions.CriticalError( id_="FAILED_TO_DOWNLOAD_TRANSACTION_PACKAGES", - title="Failed to download packages in the transaction.", + title="Failed to download packages in the transaction", description="During package transaction dnf failed to download the necessary packages needed for the transaction.", diagnosis="Package download failed with error {}.".format(str(e)), ) @@ -231,11 +231,11 @@ def _process_transaction(self, validate_transaction): pkgmanager.exceptions.TransactionCheckError, ) as e: logger.debug("Got the following exception message: %s", e) - logger.critical_no_exit("Failed to validate the dnf transaction.") + logger.critical_no_exit("Failed to validate a dnf transaction.") raise exceptions.CriticalError( - id_="FAILED_TO_VALIDATE_TRANSACTION", - title="Failed to validate dnf transaction.", - description="During the dnf transaction execution an error occured and convert2rhel could no longer process the transaction.", + id_="FAILED_TO_VALIDATE_DNF_TRANSACTION", + title="Failed to validate a dnf transaction", + description="During the dnf transaction execution an error occurred and convert2rhel could no longer process the transaction.", diagnosis="Transaction processing failed with error: {}".format(str(e)), ) diff --git a/convert2rhel/pkgmanager/handlers/yum/__init__.py b/convert2rhel/pkgmanager/handlers/yum/__init__.py index 5449e7c139..864d359778 100644 --- a/convert2rhel/pkgmanager/handlers/yum/__init__.py +++ b/convert2rhel/pkgmanager/handlers/yum/__init__.py @@ -168,7 +168,7 @@ def _enable_repos(self): logger.critical_no_exit("Failed to populate repository metadata.") raise exceptions.CriticalError( id_="FAILED_TO_ENABLE_REPOS", - title="Failed to enable repositories.", + title="Failed to enable repositories", description="We've encountered a failure when accessing repository metadata.", diagnosis="Loading repository metadata failed with error {}.".format(str(e)), ) @@ -236,7 +236,7 @@ def _perform_operations(self): logger.critical_no_exit("There are no suitable mirrors available for the loaded repositories.") raise exceptions.CriticalError( id_="FAILED_TO_LOAD_REPOSITORIES", - title="Failed to find suitable mirrors for the load repositories.", + title="Failed to find suitable mirrors for the load repositories", description="All available mirrors were tried and none were available.", diagnosis="Repository mirrors failed with error {}.".format(str(e)), ) @@ -318,10 +318,10 @@ def _process_transaction(self, validate_transaction): # - pkgmanager.Errors.YumBaseError # - pkgmanager.Errors.YumGPGCheckError logger.debug("Got the following exception message: %s", e) - logger.critical_no_exit("Failed to validate the yum transaction.") + logger.critical_no_exit("Failed to validate a yum transaction.") raise exceptions.CriticalError( - id_="FAILED_TO_VALIDATE_TRANSACTION", - title="Failed to validate yum transaction.", + id_="FAILED_TO_VALIDATE_YUM_TRANSACTION", + title="Failed to validate a yum transaction", description="During the yum transaction execution an error occurred and convert2rhel could no longer process the transaction.", diagnosis="Transaction processing failed with error: {}".format(" ".join(e.value)), ) @@ -364,7 +364,7 @@ def run_transaction(self, validate_transaction=False): logger.critical_no_exit("Failed to resolve dependencies in the transaction.") raise exceptions.CriticalError( id_="FAILED_TO_RESOLVE_DEPENDENCIES", - title="Failed to resolve dependencies.", + title="Failed to resolve dependencies", description="During package transaction yum failed to resolve the necessary dependencies needed for a package replacement.", ) finally: diff --git a/convert2rhel/subscription.py b/convert2rhel/subscription.py index a235a6f397..6cc611155d 100644 --- a/convert2rhel/subscription.py +++ b/convert2rhel/subscription.py @@ -216,8 +216,8 @@ def register_system(): ) ) raise exceptions.CriticalError( - id_="FAILED_TO_SUBSCRIBE_SYSTEM", - title="Failed to subscribe system.", + id_="FAILED_TO_SUBSCRIBE_SYSTEM_ETC_OS_RELEASE", + title="Failed to restore /etc/os-release", description="Failed to restore the /etc/os-release file needed for subscribing the system.", diagnosis="The restore failed with error {}.".format(str(e)), ) @@ -247,8 +247,10 @@ def register_system(): logger.critical_no_exit("Unable to register the system through subscription-manager.") raise exceptions.CriticalError( id_="FAILED_TO_SUBSCRIBE_SYSTEM", - title="Failed to subscribe system.", - description="After several attempts, convert2rhel was unable to subscribe the system using subscription-manager. This issue might occur because of but not limited to DBus, file permission-related issues, bad credentials, or network issues.", + title="Failed to subscribe the system", + description="After several attempts, convert2rhel was unable to subscribe the system using" + " subscription-manager. This issue might occur because of but not limited to DBus," + " file permission-related issues, bad credentials, or network issues.", diagnosis="System registration failed with error {}.".format(str(troublesome_exception)), ) @@ -711,7 +713,7 @@ def attach_subscription(): ) raise exceptions.CriticalError( id_="FAILED_TO_ATTACH_SUBSCRIPTION", - title="Failed to attach a subscription to the system.", + title="Failed to attach a subscription to the system", description="convert2rhel was unable to attach a subscription to the system. An attached subscription is required for RHEL package installation.", remediations="Refer to https://access.redhat.com/management/ where you can enable Simple Content Access, create an activation key, or find a Pool ID of the subscription you wish to use and pass it to convert2rhel through the `--pool` CLI option.", ) @@ -735,7 +737,7 @@ def verify_rhsm_installed(): ) raise exceptions.CriticalError( id_="FAILED_TO_VERIFY_SUBSCRIPTION_MANAGER", - title="Failed to verify subscription-manager package.", + title="Failed to verify the subscription-manager package", description="The subscription-manager package is not installed correctly. Therefore, the pre-conversion analysis cannot verify that the correct package is installed on your system.", remediations="Manually installing subscription-manager before running convert2rhel.", ) @@ -756,7 +758,7 @@ def disable_repos(): logger.critical_no_exit("Could not disable subscription-manager repositories:\n{}".format(output)) raise exceptions.CriticalError( id_="FAILED_TO_DISABLE_SUBSCRIPTION_MANAGER_REPOSITORIES", - title="Could not disable repositories through subscription-manager.", + title="Could not disable repositories through subscription-manager", description="As part of the conversion process, convert2rhel disables all current subscription-manager repositories and enables only repositories required for the conversion. convert2rhel was unable to disable these repositories, and the conversion is unable to proceed.", diagnosis="Failed to disable repositories: {}.".format(output), ) diff --git a/convert2rhel/toolopts/__init__.py b/convert2rhel/toolopts/__init__.py index 14c6854677..c09cbdb8f9 100644 --- a/convert2rhel/toolopts/__init__.py +++ b/convert2rhel/toolopts/__init__.py @@ -99,8 +99,8 @@ def _handle_config_conflict(self, config_sources): message = ( "We need to run the 'rpm -Va' command to be able to perform a complete rollback of changes" " done to the system during the pre-conversion analysis. If you accept the risk of an" - " incomplete rollback, set the CONVERT2RHEL_INCOMPLETE_ROLLBACK=1 environment" - " variable. Otherwise, remove the --no-rpm-va option." + " incomplete rollback, set the incomplete_rollback option to true in the /etc/convert2rhel.ini" + " config file. Otherwise, remove the --no-rpm-va option." ) loggerinst.critical(message) diff --git a/convert2rhel/unit_tests/actions/post_conversion/hostmetering_test.py b/convert2rhel/unit_tests/actions/post_conversion/hostmetering_test.py index 6befe3ff23..3c824a6f7f 100644 --- a/convert2rhel/unit_tests/actions/post_conversion/hostmetering_test.py +++ b/convert2rhel/unit_tests/actions/post_conversion/hostmetering_test.py @@ -167,7 +167,7 @@ def test_configure_host_metering( hostmetering_instance, level="ERROR", id="HOST_METERING_NOT_RUNNING", - title="Host metering service is not running.", + title="Host metering service is not running", description="host-metering.service is not running.", remediations="You can try to start the service manually" " by running following command:\n" @@ -194,16 +194,12 @@ 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.", - ), - ), - ), + {actions.ActionMessage( + level="INFO", + id="CONFIGURE_HOST_METERING_SKIP_ONLY_RHEL_7", + title="Did not perform host metering configuration", + description="Host metering is supported only for RHEL 7.", + )}, actions.ActionResult(level="SUCCESS", id="SUCCESS"), ), ( @@ -213,18 +209,14 @@ def test_configure_host_metering( (None, 0), ("", ""), True, - set( - ( - actions.ActionMessage( - level="WARNING", - id="FORCED_CONFIGURE_HOST_METERING", - title="The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", - description="Please note that this option is mainly used for testing and" - " will configure host-metering unconditionally." - " For generic usage please use the 'auto' option.", - ), - ), - ), + {actions.ActionMessage( + level="WARNING", + id="FORCED_CONFIGURE_HOST_METERING", + title="Configuration of host metering set to 'force'", + description="Please note that this option is mainly used for testing and" + " will configure host-metering unconditionally." + " For generic usage please use the 'auto' option.", + )}, actions.ActionResult(level="SUCCESS", id="SUCCESS"), ), ( @@ -234,17 +226,15 @@ def test_configure_host_metering( (None, 0), ("", ""), None, - set( - ( - actions.ActionMessage( - level="WARNING", - id="UNRECOGNIZED_OPTION_CONFIGURE_HOST_METERING", - title="Unrecognized option in CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", - description="Environment variable wrong_env not recognized.", - remediations="Set the option to `auto` value if you want to configure host metering.", - ), - ), - ), + {actions.ActionMessage( + level="WARNING", + id="UNRECOGNIZED_OPTION_CONFIGURE_HOST_METERING", + title="Unexpected value of the host metering setting", + diagnosis="Unexpected value of 'configure_host_metering' in convert2rhel.ini or the" + " CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: wrong_env", + description="Host metering will not be configured.", + remediations="Set the option to 'auto' or 'force' if you want to configure host metering.", + )}, actions.ActionResult(level="SUCCESS", id="SUCCESS"), ), ( @@ -254,16 +244,12 @@ 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.", - ), - ), - ), + {actions.ActionMessage( + level="INFO", + id="CONFIGURE_HOST_METERING_SKIP_NOT_HYPERSCALER", + title="Did not perform host metering configuration", + description="Host metering is not needed on the system as it is not running on a hyperscaler.", + )}, actions.ActionResult(level="SUCCESS", id="SUCCESS"), ), ( @@ -273,23 +259,19 @@ def test_configure_host_metering( ("yum install fail", 1), ("", ""), None, - set( - ( - actions.ActionMessage( - level="WARNING", - id="INSTALL_HOST_METERING_FAILURE", - title="Failed to install host metering package.", - description="When installing host metering package an error occurred meaning we can't" - " enable host metering on the system.", - diagnosis="`yum install host-metering` command returned 1 with message yum install fail", - remediations="You can try install and set up the host metering" - " manually using following commands:\n" - " - `yum install host-metering`\n" - " - `systemctl enable host-metering.service`\n" - " - `systemctl start host-metering.service`", - ), - ) - ), + {actions.ActionMessage( + level="WARNING", + id="INSTALL_HOST_METERING_FAILURE", + title="Failed to install the host-metering package", + description="When installing the host-metering package an error occurred meaning we can't" + " enable host metering on the system.", + diagnosis="`yum install host-metering` command returned 1 with message yum install fail", + remediations="You can try install and set up the host metering" + " manually using following commands:\n" + " - `yum install host-metering`\n" + " - `systemctl enable host-metering.service`\n" + " - `systemctl start host-metering.service`", + )}, actions.ActionResult(level="SUCCESS", id="SUCCESS"), ), ( @@ -299,22 +281,18 @@ def test_configure_host_metering( ("", 0), ("systemctl enable host-metering.service", "Failed to enable"), None, - set( - ( - actions.ActionMessage( - level="WARNING", - id="CONFIGURE_HOST_METERING_FAILURE", - title="Failed to enable and start host metering service.", - description="The host metering service failed to start" - " successfully and won't be able to keep track.", - diagnosis="Command systemctl enable host-metering.service failed with Failed to enable", - remediations="You can try set up the host metering" - " service manually using following commands:\n" - " - `systemctl enable host-metering.service`\n" - " - `systemctl start host-metering.service`", - ), - ) - ), + {actions.ActionMessage( + level="WARNING", + id="CONFIGURE_HOST_METERING_FAILURE", + title="Failed to enable and start the host metering service", + description="The host metering service failed to start successfully and won't" + " be able to report on the use of the system for the billing purposes.", + diagnosis="Command systemctl enable host-metering.service failed with Failed to enable", + remediations="You can try set up the host metering" + " service manually using following commands:\n" + " - `systemctl enable host-metering.service`\n" + " - `systemctl start host-metering.service`", + )}, actions.ActionResult(level="SUCCESS", id="SUCCESS"), ), ( @@ -328,7 +306,7 @@ def test_configure_host_metering( actions.ActionResult( level="ERROR", id="HOST_METERING_NOT_RUNNING", - title="Host metering service is not running.", + title="Host metering service is not running", description="host-metering.service is not running.", remediations="You can try to start the service manually" " by running following command:\n" @@ -383,16 +361,14 @@ def test_configure_host_metering_messages_and_results( def test_configure_host_metering_no_env_var(monkeypatch, hostmetering_instance, global_tool_opts): - expected = set( - ( - actions.ActionMessage( - level="INFO", - id="CONFIGURE_HOST_METERING_SKIP", - title="Did not perform host metering configuration.", - description="CONVERT2RHEL_CONFIGURE_HOST_METERING was not set.", - ), - ), - ) + expected = {actions.ActionMessage( + level="INFO", + id="CONFIGURE_HOST_METERING_SKIP_OPTION_NOT_DETECTED", + 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.", + )} monkeypatch.setattr(hostmetering, "tool_opts", global_tool_opts) hostmetering_instance.run() diff --git a/convert2rhel/unit_tests/actions/post_conversion/modified_rpm_files_diff_test.py b/convert2rhel/unit_tests/actions/post_conversion/modified_rpm_files_diff_test.py index 5a29e1919e..b0ad28bdbc 100644 --- a/convert2rhel/unit_tests/actions/post_conversion/modified_rpm_files_diff_test.py +++ b/convert2rhel/unit_tests/actions/post_conversion/modified_rpm_files_diff_test.py @@ -50,7 +50,7 @@ def test_modified_rpm_files_diff_with_no_rpm_va( actions.ActionMessage( level="INFO", id="SKIPPED_MODIFIED_RPM_FILES_DIFF", - title="Skipped comparison of 'rpm -Va' output from before and after the conversion.", + title="Skipped comparison of 'rpm -Va' output from before and after the conversion", description="Comparison of 'rpm -Va' output was not performed due to missing output " "of the 'rpm -Va' run before the conversion.", diagnosis="This is caused mainly by using '--no-rpm-va' argument for convert2rhel.", @@ -81,7 +81,7 @@ def test_modified_rpm_files_diff_with_no_rpm_va( actions.ActionMessage( level="INFO", id="FOUND_MODIFIED_RPM_FILES", - title="Modified rpm files from before and after the conversion were found.", + title="Modified rpm files from before and after the conversion were found", description="Comparison of modified rpm files from before and after the conversion: \n" "--- {path}/rpm_va.log\n" "+++ {path}/rpm_va_after_conversion.log\n" diff --git a/convert2rhel/unit_tests/actions/post_conversion/remove_tmp_dir_test.py b/convert2rhel/unit_tests/actions/post_conversion/remove_tmp_dir_test.py index 64377157f7..368fe2e36e 100644 --- a/convert2rhel/unit_tests/actions/post_conversion/remove_tmp_dir_test.py +++ b/convert2rhel/unit_tests/actions/post_conversion/remove_tmp_dir_test.py @@ -63,7 +63,7 @@ def test_remove_tmp_dir_failure(remove_tmp_dir_instance, monkeypatch, tmpdir, ca actions.ActionMessage( id="UNSUCCESSFUL_REMOVE_TMP_DIR", level="WARNING", - title="Temporary folder {tmp_dir} wasn't removed.".format(tmp_dir=path), + title="Temporary folder {tmp_dir} wasn't removed".format(tmp_dir=path), description=expected_message, ), ), diff --git a/convert2rhel/unit_tests/actions/pre_ponr_changes/backup_system_test.py b/convert2rhel/unit_tests/actions/pre_ponr_changes/backup_system_test.py index adadd7ee6a..2da7d7430a 100644 --- a/convert2rhel/unit_tests/actions/pre_ponr_changes/backup_system_test.py +++ b/convert2rhel/unit_tests/actions/pre_ponr_changes/backup_system_test.py @@ -95,7 +95,7 @@ def test_backup_redhat_release_calls(self, backup_redhat_release_action, monkeyp def test_backup_redhat_release_error_system_release_file(self, backup_redhat_release_action, monkeypatch): mock_sys_release_file = RestorableFileBackupMocked( id_="FAILED_TO_SAVE_FILE_TO_BACKUP_DIR", - title="Failed to copy file to the backup directory.", + title="Failed to copy file to the backup directory", description="Failure while backing up a file.", diagnosis="Failed to backup /etc/system-release. Errno: 2, Error: File not found", ) @@ -107,7 +107,7 @@ def test_backup_redhat_release_error_system_release_file(self, backup_redhat_rel backup_redhat_release_action, level="ERROR", id="FAILED_TO_SAVE_FILE_TO_BACKUP_DIR", - title="Failed to copy file to the backup directory.", + title="Failed to copy file to the backup directory", description="Failure while backing up a file.", diagnosis="Failed to backup /etc/system-release. Errno: 2, Error: File not found", ) @@ -116,7 +116,7 @@ def test_backup_redhat_release_error_os_release_file(self, backup_redhat_release mock_sys_release_file = mock.create_autospec(backup_system.system_release_file.enable) mock_os_release_file = RestorableFileBackupMocked( id_="FAILED_TO_SAVE_FILE_TO_BACKUP_DIR", - title="Failed to copy file to the backup directory.", + title="Failed to copy file to the backup directory", description="Failure while backing up a file.", diagnosis="Failed to backup /etc/os-release. Errno: 2, Error: File not found", ) @@ -130,7 +130,7 @@ def test_backup_redhat_release_error_os_release_file(self, backup_redhat_release backup_redhat_release_action, level="ERROR", id="FAILED_TO_SAVE_FILE_TO_BACKUP_DIR", - title="Failed to copy file to the backup directory.", + title="Failed to copy file to the backup directory", description="Failure while backing up a file.", diagnosis="Failed to backup /etc/os-release. Errno: 2, Error: File not found", ) @@ -223,7 +223,7 @@ def test_get_changed_package_files(self, rpm_va_output, expected, message, caplo def test_get_changed_package_files_missing( self, caplog, tmpdir, monkeypatch, backup_package_files_action, global_tool_opts ): - message = "Skipping backup of the package files. CONVERT2RHEL_INCOMPLETE_ROLLBACK detected." + message = "You have set the incomplete rollback inhibitor override - skipping backup of the package files." monkeypatch.setattr(backup_system, "LOG_DIR", str(tmpdir)) monkeypatch.setenv("CONVERT2RHEL_INCOMPLETE_ROLLBACK", "1") monkeypatch.setattr(toolopts, "tool_opts", global_tool_opts) diff --git a/convert2rhel/unit_tests/actions/pre_ponr_changes/handle_packages_test.py b/convert2rhel/unit_tests/actions/pre_ponr_changes/handle_packages_test.py index 1333bd8bee..6f1eb0a23c 100644 --- a/convert2rhel/unit_tests/actions/pre_ponr_changes/handle_packages_test.py +++ b/convert2rhel/unit_tests/actions/pre_ponr_changes/handle_packages_test.py @@ -256,7 +256,7 @@ def test_run_packages_error(self, monkeypatch, remove_special_packages_instance) remove_special_packages_instance, level="ERROR", id="SPECIAL_PACKAGE_REMOVAL_FAILED", - title="Failed to remove some packages necessary for the conversion.", + title="Failed to remove some packages necessary for the conversion", description="The cause of this error is unknown, please look at the diagnosis for more information.", diagnosis="Raising SystemExit", ) diff --git a/convert2rhel/unit_tests/actions/pre_ponr_changes/kernel_modules_test.py b/convert2rhel/unit_tests/actions/pre_ponr_changes/kernel_modules_test.py index fe5a7289a1..7994d36ace 100644 --- a/convert2rhel/unit_tests/actions/pre_ponr_changes/kernel_modules_test.py +++ b/convert2rhel/unit_tests/actions/pre_ponr_changes/kernel_modules_test.py @@ -230,17 +230,17 @@ def test_ensure_compatibility_of_kmods_check_env_and_message( ensure_kernel_modules_compatibility_instance.run() should_be_in_logs = ( - ".*Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable." - " We will continue the conversion with the following kernel modules unavailable in RHEL:.*" + ".*You have set the option to allow unavailable kernel modules." + " The conversion will continue with the following kernel modules unavailable in RHEL:.*" ) assert re.match(pattern=should_be_in_logs, string=caplog.records[-1].message, flags=re.MULTILINE | re.DOTALL) # cannot assert exact action message contents as the kmods arrangement in the message is not static message = ensure_kernel_modules_compatibility_instance.messages[0] assert STATUS_CODE["WARNING"] == message.level assert "ALLOW_UNAVAILABLE_KERNEL_MODULES" == message.id - assert "Did not perform the ensure kernel modules compatibility check" == message.title - assert "Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable." in message.description - assert "We will continue the conversion with the following kernel modules unavailable in RHEL:" in message.diagnosis + assert "Ignoring the check ensuring kernel module availability in RHEL" == message.title + assert "We will continue the conversion with the following kernel modules unavailable in RHEL:" in message.description + assert "You have set the option to allow unavailable kernel modules." in message.diagnosis @pytest.mark.parametrize( diff --git a/convert2rhel/unit_tests/actions/system_checks/check_firewalld_availability_test.py b/convert2rhel/unit_tests/actions/system_checks/check_firewalld_availability_test.py index 140c38d5fa..a0939eba12 100644 --- a/convert2rhel/unit_tests/actions/system_checks/check_firewalld_availability_test.py +++ b/convert2rhel/unit_tests/actions/system_checks/check_firewalld_availability_test.py @@ -299,7 +299,7 @@ def test_cleanup_modules_on_exit_is_true( check_firewalld_availability_is_running_action, level="ERROR", id="FIREWALLD_MODULES_CLEANUP_ON_EXIT_CONFIG", - title="Firewalld is set to cleanup modules after exit.", + title="Firewalld is set to cleanup modules after exit", description="Firewalld running on Oracle Linux 8 can lead to a conversion failure.", diagnosis=( "We've detected that firewalld unit is running and that causes iptables and nftables " diff --git a/convert2rhel/unit_tests/actions/system_checks/convert2rhel_latest_test.py b/convert2rhel/unit_tests/actions/system_checks/convert2rhel_latest_test.py index 8686df3524..f72a123c1e 100644 --- a/convert2rhel/unit_tests/actions/system_checks/convert2rhel_latest_test.py +++ b/convert2rhel/unit_tests/actions/system_checks/convert2rhel_latest_test.py @@ -162,7 +162,8 @@ def test_convert2rhel_latest_outdated_version_inhibitor( "You are currently running {} and the latest version of convert2rhel is {}.\n" "Only the latest version is supported for conversion.".format(running_version, latest_version) ), - remediations="If you want to disregard this check, then set the environment variable 'CONVERT2RHEL_ALLOW_OLDER_VERSION=1' to continue.", + remediations="If you want to disregard this check, set the allow_older_version inhibitor" + " override in the /etc/convert2rhel.ini config file to true.", ) @pytest.mark.parametrize( @@ -337,7 +338,7 @@ def test_convert2rhel_latest_log_check_env( log_msg = ( "You are currently running {} and the latest version of convert2rhel is {}.\n" - "'CONVERT2RHEL_ALLOW_OLDER_VERSION' environment variable detected, continuing conversion".format( + "You have set the option to allow older convert2rhel version, continuing conversion".format( running_version, latest_version ) ) @@ -769,7 +770,8 @@ def test_convert2rhel_latest_bad_nevra_to_parse_pkg_string( "You are currently running {} and the latest version of convert2rhel is {}.\n" "Only the latest version is supported for conversion.".format(running_version, latest_version) ), - remediations="If you want to disregard this check, then set the environment variable 'CONVERT2RHEL_ALLOW_OLDER_VERSION=1' to continue.", + remediations="If you want to disregard this check, set the allow_older_version inhibitor" + " override in the /etc/convert2rhel.ini config file to true." ) def test_convert2rhel_latest_unable_to_get_c2r_repofile( diff --git a/convert2rhel/unit_tests/actions/system_checks/is_loaded_kernel_latest_test.py b/convert2rhel/unit_tests/actions/system_checks/is_loaded_kernel_latest_test.py index 10da0b684a..2592db4720 100644 --- a/convert2rhel/unit_tests/actions/system_checks/is_loaded_kernel_latest_test.py +++ b/convert2rhel/unit_tests/actions/system_checks/is_loaded_kernel_latest_test.py @@ -372,12 +372,10 @@ def test_is_loaded_kernel_latest_eus_system( "WARNING", "UNSUPPORTED_SKIP_KERNEL_CURRENCY_CHECK_DETECTED", "Did not perform the kernel currency check", - ( - "Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip the kernel-core comparison.\nBeware, this could leave your system in a broken state." - ), - None, + "We will not be checking if the loaded kernel is of the latest version available." \ + "\nBeware, this could leave your system in a broken state.", + "You have set the option to skip the kernel currency check.", None, - id="Unsupported skip with environment var set to 1", ), ), ) @@ -428,18 +426,14 @@ def test_is_loaded_kernel_latest_skip_warnings( {"CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK": skip_check}, ) - expected_set = set( - ( - actions.ActionMessage( - level=level, - id=id, - title=title, - description=description, - diagnosis=diagnosis, - remediations=remediations, - ), - ) - ) + expected_set = {actions.ActionMessage( + level=level, + id=id, + title=title, + description=description, + diagnosis=diagnosis, + remediations=remediations, + )} is_loaded_kernel_latest_action.run() assert description in caplog.records[-1].message assert expected_set.issuperset(is_loaded_kernel_latest_action.messages) @@ -466,7 +460,7 @@ def test_is_loaded_kernel_latest_skip_warnings( "Unable to fetch recent kernels", ( "Couldn't fetch the list of the most recent kernels available in " - "the repositories. Did not perform the loaded kernel check." + "the repositories. Did not perform the loaded kernel currency check." ), None, None, @@ -555,8 +549,8 @@ def test_is_loaded_kernel_latest_unable_to_fetch_kernels( "Could not find any {0} from repositories to compare against the loaded kernel.", ( "Please, check if you have any vendor repositories enabled to proceed with the conversion.\n" - "If you wish to disregard this message, set the environment variable " - "'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1." + "If you wish to disregard this message, set the skip_kernel_currency_check inhibitor override in" + " the /etc/convert2rhel.ini config file to true." ), id="Repoquery failure without environment var", ), diff --git a/convert2rhel/unit_tests/actions/system_checks/tainted_kmods_test.py b/convert2rhel/unit_tests/actions/system_checks/tainted_kmods_test.py index adacfddc6e..1213257581 100644 --- a/convert2rhel/unit_tests/actions/system_checks/tainted_kmods_test.py +++ b/convert2rhel/unit_tests/actions/system_checks/tainted_kmods_test.py @@ -80,13 +80,13 @@ def test_check_tainted_kmods(monkeypatch, command_return, is_error, tainted_kmod remediations=( "Prevent the modules from loading by following {0}" " and run convert2rhel again to continue with the conversion." - " Although it is not recommended, you can disregard this message by setting the environment variable" - " 'CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP' to 1. Overriding this check can be dangerous" + " Although it is not recommended, you can disregard this message by setting the" + " tainted_kernel_module_check_skip inhibitor override in the /etc/convert2rhel.ini" + " config file to true. Overriding this check can be dangerous" " so it is recommended that you do a system backup beforehand." - " For information on what a tainted kernel module is, please refer to this documentation {1}".format( - LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS - ) - ), + " For information on what a tainted kernel module is, please refer to this documentation {1}" + .format(LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS) + ) ) @@ -121,37 +121,32 @@ def test_check_tainted_kmods_skip(monkeypatch, command_return, is_error, tainted tainted_kmods_action.run() if is_error: - expected = set( - ( - actions.ActionMessage( - level="WARNING", - id="TAINTED_KMODS_DETECTED_MESSAGE", - title="Tainted kernel modules detected", - description="Please refer to the diagnosis for further information", - diagnosis=( - "Tainted kernel modules detected:\n system76_io\n system76_acpi\nThird-party " - "components are not supported per our software support" - " policy:\n{}\n".format(LINK_KMODS_RH_POLICY) - ), - remediations=( - "Prevent the modules from loading by following {0}" - " and run convert2rhel again to continue with the conversion." - " For information on what a tainted kernel module is, please refer to this documentation {1}".format( - LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS - ) - ), - ), - actions.ActionMessage( - level="WARNING", - id="SKIP_TAINTED_KERNEL_MODULE_CHECK", - title="Skip tainted kernel module check", - description=( - "Detected 'CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP' environment variable, we will skip " - "the tainted kernel module check.\n" - "Beware, this could leave your system in a broken state." - ), - ), - ) - ) + expected = {actions.ActionMessage( + level="WARNING", + id="TAINTED_KMODS_DETECTED_MESSAGE", + title="Tainted kernel modules detected", + description="Please refer to the diagnosis for further information", + diagnosis=( + "Tainted kernel modules detected:\n system76_io\n system76_acpi\nThird-party " + "components are not supported per our software support" + " policy:\n{}\n".format(LINK_KMODS_RH_POLICY) + ), + remediations=( + "Prevent the modules from loading by following {0}" + " and run convert2rhel again to continue with the conversion." + " For information on what a tainted kernel module is, please refer to this documentation {1}".format( + LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS + ) + ), + ), actions.ActionMessage( + level="WARNING", + id="SKIP_TAINTED_KERNEL_MODULE_CHECK", + title="Skip tainted kernel module check", + diagnosis="You have set the option to skip the tainted kernel module check.", + description=( + "We will ignore results of the check that makes sure no tainted kernel modules are loaded.\n" + "Beware, this could leave your system in a broken state." + ), + )} assert expected.issuperset(tainted_kmods_action.messages) assert expected.issubset(tainted_kmods_action.messages) diff --git a/convert2rhel/unit_tests/cli_test.py b/convert2rhel/unit_tests/cli_test.py index e290ba0416..d780b5d829 100644 --- a/convert2rhel/unit_tests/cli_test.py +++ b/convert2rhel/unit_tests/cli_test.py @@ -543,7 +543,10 @@ def test_critical_exit_no_rpm_va_setting(monkeypatch, global_tool_opts, tmpdir): monkeypatch.setattr(sys, "argv", mock_cli_arguments(["--no-rpm-va"])) with pytest.raises( SystemExit, - match="We need to run the 'rpm -Va' command to be able to perform a complete rollback of changes done to the system during the pre-conversion analysis. If you accept the risk of an incomplete rollback, set the CONVERT2RHEL_INCOMPLETE_ROLLBACK=1 environment variable. Otherwise, remove the --no-rpm-va option.", + match="We need to run the 'rpm -Va' command to be able to perform a complete rollback of changes" + " done to the system during the pre-conversion analysis. If you accept the risk of an" + " incomplete rollback, set the incomplete_rollback option to true in the /etc/convert2rhel.ini" + " config file. Otherwise, remove the --no-rpm-va option." ): cli.CLI() diff --git a/convert2rhel/unit_tests/pkgmanager/handlers/dnf/dnf_test.py b/convert2rhel/unit_tests/pkgmanager/handlers/dnf/dnf_test.py index ceae3ac05d..c63bfe50b0 100644 --- a/convert2rhel/unit_tests/pkgmanager/handlers/dnf/dnf_test.py +++ b/convert2rhel/unit_tests/pkgmanager/handlers/dnf/dnf_test.py @@ -350,11 +350,11 @@ def test_process_transaction_exceptions(self, pretend_os, caplog): instance._process_transaction(validate_transaction=False) assert pkgmanager.Base.do_transaction.call_count == 1 - assert "Failed to validate the dnf transaction." in caplog.records[-1].message - assert "FAILED_TO_VALIDATE_TRANSACTION" in execinfo._excinfo[1].id - assert "Failed to validate dnf transaction." in execinfo._excinfo[1].title + assert "Failed to validate a dnf transaction." in caplog.records[-1].message + assert "FAILED_TO_VALIDATE_DNF_TRANSACTION" in execinfo._excinfo[1].id + assert "Failed to validate a dnf transaction" in execinfo._excinfo[1].title assert ( - "During the dnf transaction execution an error occured and convert2rhel could no longer process the transaction." + "During the dnf transaction execution an error occurred and convert2rhel could no longer process the transaction." in execinfo._excinfo[1].description ) assert ( @@ -364,7 +364,7 @@ def test_process_transaction_exceptions(self, pretend_os, caplog): @centos8 @pytest.mark.parametrize( - ("validate_transaction"), + "validate_transaction", ((True), (False)), ) def test_run_transaction(self, pretend_os, validate_transaction, caplog, monkeypatch): diff --git a/convert2rhel/unit_tests/pkgmanager/handlers/yum/yum_test.py b/convert2rhel/unit_tests/pkgmanager/handlers/yum/yum_test.py index f7575976f5..84b6f09316 100644 --- a/convert2rhel/unit_tests/pkgmanager/handlers/yum/yum_test.py +++ b/convert2rhel/unit_tests/pkgmanager/handlers/yum/yum_test.py @@ -248,9 +248,9 @@ def test_process_transaction_with_exceptions(self, pretend_os, caplog, monkeypat with pytest.raises(exceptions.CriticalError) as execinfo: instance._process_transaction(validate_transaction=False) - assert "Failed to validate the yum transaction." in caplog.records[-1].message - assert "FAILED_TO_VALIDATE_TRANSACTION" in execinfo._excinfo[1].id - assert "Failed to validate yum transaction." in execinfo._excinfo[1].title + assert "Failed to validate a yum transaction." in caplog.records[-1].message + assert "FAILED_TO_VALIDATE_YUM_TRANSACTION" in execinfo._excinfo[1].id + assert "Failed to validate a yum transaction" in execinfo._excinfo[1].title assert ( "During the yum transaction execution an error occurred and convert2rhel could no longer process the transaction." in execinfo._excinfo[1].description diff --git a/convert2rhel/unit_tests/toolopts/toolopts_test.py b/convert2rhel/unit_tests/toolopts/toolopts_test.py index be73cba027..847a8d3b33 100644 --- a/convert2rhel/unit_tests/toolopts/toolopts_test.py +++ b/convert2rhel/unit_tests/toolopts/toolopts_test.py @@ -333,8 +333,8 @@ def test_handle_config_conflicts_system_exit(config_sources): match=( "We need to run the 'rpm -Va' command to be able to perform a complete rollback of changes" " done to the system during the pre-conversion analysis. If you accept the risk of an" - " incomplete rollback, set the CONVERT2RHEL_INCOMPLETE_ROLLBACK=1 environment" - " variable. Otherwise, remove the --no-rpm-va option." + " incomplete rollback, set the incomplete_rollback option to true in the /etc/convert2rhel.ini" + " config file. Otherwise, remove the --no-rpm-va option." ), ): tool_opts.initialize(config_sources) diff --git a/convert2rhel/unit_tests/utils/utils_test.py b/convert2rhel/unit_tests/utils/utils_test.py index cff9c219dd..c1ad947666 100644 --- a/convert2rhel/unit_tests/utils/utils_test.py +++ b/convert2rhel/unit_tests/utils/utils_test.py @@ -1141,10 +1141,10 @@ def test_remove_epoch_from_yum_nevra_notation(pkg_nevra, nvra_without_epoch): ( ( "CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK", - True, + "1", "skip_kernel_currency_check", - "The environment variable CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK is deprecated and is set to be removed on Convert2RHEL 2.4.0.\n" - "Please, use the configuration file instead.", + "Using the environment variable CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK is deprecated and it will to be removed in convert2rhel 2.4.0.\n" + "Use the skip_kernel_currency_check option in the /etc/convert2rhel.ini configuration file.", ), ), ) diff --git a/convert2rhel/utils/__init__.py b/convert2rhel/utils/__init__.py index b0542bfb4a..f37a074e08 100644 --- a/convert2rhel/utils/__init__.py +++ b/convert2rhel/utils/__init__.py @@ -722,7 +722,7 @@ def remove_pkgs(pkgs_to_remove, critical=True): logger.critical_no_exit("Error: Couldn't remove {}.".format(pkgs_as_str)) raise exceptions.CriticalError( id_="FAILED_TO_REMOVE_PACKAGES", - title="Couldn't remove packages.", + title="Couldn't remove packages", description="While attempting to roll back changes, we encountered an unexpected failure while attempting to remove one or more of the packages we installed earlier.", diagnosis="Couldn't remove {}.".format(pkgs_as_str), ) @@ -1144,8 +1144,9 @@ def warn_deprecated_env(env_name): return None root_logger.warning( - "The environment variable {} is deprecated and is set to be removed on Convert2RHEL 2.4.0.\n" - "Please, use the configuration file instead.".format(env_name) + "Using the environment variable {} is deprecated and it will to be removed in convert2rhel 2.4.0.\n" + "Use the {} option in the /etc/convert2rhel.ini configuration file." + .format(env_name, env_var_to_toolopts_map[env_name]) ) key = env_var_to_toolopts_map[env_name] value = os.getenv(env_name, None)