Skip to content

Commit

Permalink
Format messages for consistency
Browse files Browse the repository at this point in the history
- no full stop at the end of a report message title
- no word please (technical writers' rule)
- unique report message ids
- fix typos
- add missing context where messages are too short and vague
- make TASK tense consistent
  • Loading branch information
bocekm committed Nov 27, 2024
1 parent 3ab1a44 commit 1fd0e5b
Show file tree
Hide file tree
Showing 67 changed files with 347 additions and 351 deletions.
6 changes: 3 additions & 3 deletions convert2rhel/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def run(self, successes=None, failures=None, skips=None):
title="Skipped action",
description="This action was skipped due to another action failing.",
diagnosis=diagnosis,
remediations="Please ensure that the {} check passes so that this Action can evaluate your system".format(
remediations="Ensure that the {} check passes so that this Action can evaluate your system".format(
utils.format_sequence_as_message(failed_deps)
),
)
Expand All @@ -586,7 +586,7 @@ def run(self, successes=None, failures=None, skips=None):

# Categorize the results
if action.result.level <= STATUS_CODE["WARNING"]:
logger.info("{} has succeeded".format(action.id))
logger.info("The {} action has succeeded.".format(action.id))
successes.append(action)

if action.result.level > STATUS_CODE["WARNING"]:
Expand Down Expand Up @@ -742,7 +742,7 @@ def run_pre_actions():
# When we call check_dependencies() or run() on the first Stage
# (system_checks), it will operate on the first Stage and then recursively
# call check_dependencies() or run() on the next_stage.
pre_ponr_changes = Stage("pre_ponr_changes", "Making recoverable changes")
pre_ponr_changes = Stage("pre_ponr_changes", "Make recoverable changes")
system_checks = Stage("system_checks", "Check whether system is ready for conversion", next_stage=pre_ponr_changes)

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def run(self):
super(ListNonRedHatPkgsLeft, self).run()
loggerinst.task("List remaining non-Red Hat packages")

loggerinst.info("Listing packages not signed by Red Hat")
loggerinst.info("Listing packages not signed by Red Hat.")
non_red_hat_pkgs = get_installed_pkgs_w_different_key_id(system_info.key_ids_rhel)
if not non_red_hat_pkgs:
loggerinst.info("All packages are now signed by Red Hat.")
Expand Down
14 changes: 7 additions & 7 deletions convert2rhel/actions/conversion/preserve_only_rhel_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run(self):
id="FAILED_TO_INSTALL_RHEL_KERNEL",
title="Failed to install RHEL kernel",
description="There was an error while attempting to install the RHEL kernel from yum.",
remediations="Please check that you can access the repositories that provide the RHEL kernel.",
remediations="Check that you can access the repositories that provide the RHEL kernel.",
)
return

Expand Down Expand Up @@ -131,7 +131,7 @@ def run(self):
"""Verify that the RHEL kernel has been successfully installed and raise an ERROR if not"""
super(VerifyRhelKernelInstalled, self).run()

loggerinst.info("Verifying that RHEL kernel has been installed")
loggerinst.info("Verifying that RHEL kernel has been installed.")
installed_rhel_kernels = pkghandler.get_installed_pkgs_by_key_id(system_info.key_ids_rhel, name="kernel")
if len(installed_rhel_kernels) <= 0:
self.set_result(
Expand Down Expand Up @@ -180,7 +180,7 @@ def run(self):
for entry in boot_entries:
# The boot loader entries in /boot/loader/entries/<machine-id>-<kernel-version>.conf
if machine_id not in os.path.basename(entry):
loggerinst.debug("Removing boot entry {}".format(entry))
loggerinst.debug("Removing boot entry {}.".format(entry))
os.remove(entry)

# Removing a boot entry that used to be the default makes grubby to choose a different entry as default,
Expand Down Expand Up @@ -224,7 +224,7 @@ def run(self):
"""
super(FixDefaultKernel, self).run()

loggerinst.info("Checking for incorrect boot kernel")
loggerinst.info("Checking for incorrect boot kernel.")
kernel_sys_cfg = utils.get_file_content("/etc/sysconfig/kernel")

possible_kernels = ["kernel-uek", "kernel-plus"]
Expand All @@ -246,7 +246,7 @@ def run(self):

kernel_sys_cfg = kernel_sys_cfg.replace("DEFAULTKERNEL=" + kernel_to_change, new_kernel_str)
utils.store_content_to_file("/etc/sysconfig/kernel", kernel_sys_cfg)
loggerinst.info("Boot kernel {} was changed to {}".format(kernel_to_change, new_kernel_str))
loggerinst.info("Boot kernel {} was changed to {}.".format(kernel_to_change, new_kernel_str))
else:
loggerinst.debug("Boot kernel validated.")

Expand All @@ -270,7 +270,7 @@ def remove_non_rhel_kernels(self):
loggerinst.info("None found.")
return None

loggerinst.info("Removing non-RHEL kernels\n")
loggerinst.info("Removing non-RHEL kernels.\n")
pkghandler.print_pkg_info(non_rhel_kernels)
pkgs_to_remove = [pkghandler.get_pkg_nvra(pkg) for pkg in non_rhel_kernels]
utils.remove_pkgs(pkgs_to_remove)
Expand All @@ -288,7 +288,7 @@ def install_additional_rhel_kernel_pkgs(self, additional_pkgs):
pkg_names = [p.nevra.name.replace(ol_kernel_ext, "", 1) for p in additional_pkgs]
for name in set(pkg_names):
if name != "kernel":
loggerinst.info("Installing RHEL {}".format(name))
loggerinst.info("Installing RHEL {}.".format(name))
pkgmanager.call_yum_cmd("install", args=[name])


Expand Down
2 changes: 1 addition & 1 deletion convert2rhel/actions/conversion/set_efi_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def run(self):
)
continue

logger.info("Moving '{}' to '{}'".format(src_file, dst_file))
logger.info("Moving '{}' to '{}'.".format(src_file, dst_file))

try:
shutil.move(src_file, dst_file)
Expand Down
39 changes: 21 additions & 18 deletions convert2rhel/actions/post_conversion/hostmetering.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def run(self):
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

Expand All @@ -72,9 +72,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

Expand All @@ -85,8 +85,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
Expand All @@ -105,9 +105,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
),
Expand All @@ -125,7 +125,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"
Expand All @@ -145,8 +145,8 @@ def _check_env_var(self):
logger.debug("CONVERT2RHEL_CONFIGURE_HOST_METERING was not set. Skipping it.")
self.add_message(
level="INFO",
id="CONFIGURE_HOST_METERING_SKIP",
title="Did not perform host metering configuration.",
id="CONFIGURE_HOST_METERING_SKIP_OPTION_NOT_DETECTED",
title="Did not perform host metering configuration",
description="CONVERT2RHEL_CONFIGURE_HOST_METERING was not set.",
)
return False
Expand All @@ -167,19 +167,22 @@ def _check_env_var(self):
if tool_opts.configure_host_metering == "force":
logger.warning(
"The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable."
" Please note that this option is mainly used for testing and will configure host-metering unconditionally. "
" For generic usage please use the 'auto' option."
" Note that this option is mainly used for testing and will configure host-metering unconditionally. "
" For generic usage 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.",
description="Please note that this option is mainly used for testing and"
description="Note that this option is mainly used for testing and"
" will configure host-metering unconditionally."
" For generic usage please use the 'auto' option.",
" For generic usage 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -76,8 +76,8 @@ 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.",
description="Comparison of modified rpm files from before and after " "the conversion: \n{}".format(
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
),
)
4 changes: 2 additions & 2 deletions convert2rhel/actions/post_conversion/remove_tmp_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run(self):

try:
shutil.rmtree(self.tmp_dir)
loggerinst.info("Temporary folder {} removed".format(self.tmp_dir))
loggerinst.info("Temporary folder {} removed.".format(self.tmp_dir))
except OSError as exc:
# We want run() to be idempotent, so do nothing silently if
# the path doesn't exist.
Expand All @@ -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,
)
2 changes: 1 addition & 1 deletion convert2rhel/actions/post_conversion/update_grub.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run(self):
level="ERROR",
id="FAILED_TO_IDENTIFY_GRUB2_BLOCK_DEVICE",
title="Failed to identify GRUB2 block device",
description="The block device could not be identified, please look at the diagnosis "
description="The block device could not be identified. Look at the diagnosis "
"for more information.",
diagnosis=str(e),
)
Expand Down
18 changes: 8 additions & 10 deletions convert2rhel/actions/pre_ponr_changes/backup_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class BackupRedhatRelease(actions.Action):
id = "BACKUP_REDHAT_RELEASE"

def run(self):
"""Backup redhat release file before starting conversion process"""
logger.task("Backup Redhat Release Files")
"""Back up redhat release file before starting conversion process"""
logger.task("Back up redhat-release files")

super(BackupRedhatRelease, self).run()

Expand All @@ -79,7 +79,7 @@ class BackupRepository(actions.Action):

def run(self):
"""Backup .repo files in /etc/yum.repos.d/ so the repositories can be restored on rollback."""
logger.task("Backup Repository Files")
logger.task("Back up repository Files")

super(BackupRepository, self).run()

Expand All @@ -105,7 +105,7 @@ class BackupYumVariables(actions.Action):

def run(self):
"""Backup varsdir folder in /etc/{yum,dnf}/vars so the variables can be restored on rollback."""
logger.task("Backup variables")
logger.task("Back up variables")

super(BackupYumVariables, self).run()

Expand Down Expand Up @@ -146,7 +146,7 @@ def run(self):
"""Backup changed package files"""
super(BackupPackageFiles, self).run()

logger.task("Backup package files")
logger.task("Back up package files")

package_files_changes = self._get_changed_package_files()

Expand Down Expand Up @@ -178,7 +178,6 @@ def _get_changed_package_files(self):
"""Get the output from rpm -Va command from during resolving system info
to get changes made to package files.
:return dict: Return them as a list of dict, for example:
[{"status":"S5T", "file_type":"c", "path":"/etc/yum.repos.d/CentOS-Linux-AppStream.repo"}]
"""
Expand All @@ -196,10 +195,9 @@ def _get_changed_package_files(self):
# Return empty list results in no backup of the files
return data
else:
# The file should be there
# If missing conversion is in unknown state
# The file should be there. If missing, the conversion is in an unknown state.
logger.warning("Error({}): {}".format(err.errno, err.strerror))
logger.critical("Missing file {rpm_va_output} in it's location".format(rpm_va_output=path))
logger.critical("The file {rpm_va_output} is missing.".format(rpm_va_output=path))

lines = output.strip().split("\n")
for line in lines:
Expand All @@ -217,7 +215,7 @@ def _parse_line(self, line):
if not match: # line not matching the regex
if line.strip() != "":
# Line is not empty string
logger.debug("Skipping invalid output {}".format(line))
logger.debug("Skipping invalid output: {}".format(line))
return {"status": None, "file_type": None, "path": None}

line = line.split()
Expand Down
17 changes: 9 additions & 8 deletions convert2rhel/actions/pre_ponr_changes/handle_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ def run(self):
all_pkgs = []
pkgs_removed = []
try:
logger.task("Searching for the following excluded packages")
logger.task("Remove special packages")
logger.info("Searching for the following excluded packages.")
excluded_pkgs = sorted(pkghandler.get_packages_to_remove(system_info.excluded_pkgs))

logger.task("Searching for packages containing .repo files or affecting variables in the .repo files")
logger.info("Searching for packages containing .repo files or affecting variables in the .repo files.")
repofile_pkgs = sorted(pkghandler.get_packages_to_remove(system_info.repofile_pkgs))

logger.info("\n")

all_pkgs = excluded_pkgs + repofile_pkgs
if not all_pkgs:
logger.info("No packages to backup and remove.")
logger.info("No packages to back up and remove.")
return

# We're using the backed up yum repositories to prevent the following:
Expand Down Expand Up @@ -146,8 +147,8 @@ def run(self):
self.set_result(
level="ERROR",
id="SPECIAL_PACKAGE_REMOVAL_FAILED",
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.",
title="Failed to remove some packages necessary for the conversion",
description="The cause of this error is unknown. Look at the diagnosis for more information.",
diagnosis=str(e),
)
return
Expand All @@ -161,7 +162,7 @@ def run(self):
level="WARNING",
id="SPECIAL_PACKAGES_NOT_REMOVED",
title="Special packages not removed",
description="Special packages which could not be removed",
description="Certain packages could not be removed.",
diagnosis=message,
)

Expand All @@ -170,7 +171,7 @@ def run(self):
logger.info(message)
self.add_message(
level="INFO",
id="SPECIAL_PACKAGES_REMOVED",
id="SPECIAL_PACKAGES_TO_REMOVE",
title="Special packages to be removed",
description=(
"We have identified installed packages that match a pre-defined list of packages that are"
Expand All @@ -197,7 +198,7 @@ def _remove_packages_unless_from_redhat(pkgs_list, disable_repos=None):
pkghandler.print_pkg_info(pkgs_list, disable_repos)

pkgs_removed = utils.remove_pkgs(pkghandler.get_pkg_nevras(pkgs_list))
logger.debug("Successfully removed {} packages".format(len(pkgs_list)))
logger.debug("Successfully removed {} packages.".format(len(pkgs_list)))

return pkgs_removed

Expand Down
Loading

0 comments on commit 1fd0e5b

Please sign in to comment.