Skip to content

Commit dddca52

Browse files
committed
Format messages for consistency
- no full stop at the end of a report message title - no word please (technical writers' rule) - boot loader => bootloader - fix typos - add missing context where messages are too short and vague - make TASK tense consistent - ensure each Action has a TASK level log message - ensure every Action prints what it's done - add unit tests to lines reported by caplog as uncovered
1 parent be76214 commit dddca52

File tree

85 files changed

+468
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+468
-387
lines changed

convert2rhel/actions/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def run(self, successes=None, failures=None, skips=None):
559559
title="Skipped action",
560560
description="This action was skipped due to another action failing.",
561561
diagnosis=diagnosis,
562-
remediations="Please ensure that the {} check passes so that this Action can evaluate your system".format(
562+
remediations="Ensure that the {} check passes so that this Action can evaluate your system".format(
563563
utils.format_sequence_as_message(failed_deps)
564564
),
565565
)
@@ -586,7 +586,7 @@ def run(self, successes=None, failures=None, skips=None):
586586

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

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

748748
try:

convert2rhel/actions/conversion/list_non_red_hat_pkgs_left.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def run(self):
3434
super(ListNonRedHatPkgsLeft, self).run()
3535
loggerinst.task("List remaining non-Red Hat packages")
3636

37-
loggerinst.info("Listing packages not signed by Red Hat")
37+
loggerinst.info("Listing packages not signed by Red Hat.")
3838
non_red_hat_pkgs = get_installed_pkgs_w_different_key_id(system_info.key_ids_rhel)
3939
if not non_red_hat_pkgs:
4040
loggerinst.info("All packages are now signed by Red Hat.")

convert2rhel/actions/conversion/preserve_only_rhel_kernel.py

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run(self):
3636
non-RHEL kernel(s) conflicted with the available RHEL kernels.
3737
"""
3838
super(InstallRhelKernel, self).run()
39-
loggerinst.info("Verifying that RHEL kernel has been installed")
39+
loggerinst.task("Verify RHEL kernel installation")
4040

4141
rhel_kernels = pkghandler.get_installed_pkgs_by_key_id(system_info.key_ids_rhel, name="kernel")
4242

@@ -68,8 +68,8 @@ class FixInvalidGrub2Entries(actions.Action):
6868

6969
def run(self):
7070
"""
71-
On systems derived from RHEL 8 and later, /etc/machine-id is being used to identify grub2 boot loader entries per
72-
the Boot Loader Specification.
71+
On systems derived from RHEL 8 and later, /etc/machine-id is being used to identify grub2 bootloader entries per
72+
the bootloader Specification.
7373
However, at the time of executing convert2rhel, the current machine-id can be different from the machine-id from the
7474
time when the kernels were installed. If that happens:
7575
- convert2rhel installs the RHEL kernel, but it's not set as default
@@ -79,18 +79,18 @@ def run(self):
7979
"""
8080
super(FixInvalidGrub2Entries, self).run()
8181

82+
loggerinst.task("Fix GRUB2 bootloader entries")
8283
if system_info.version.major < 8:
8384
# Applicable only on systems derived from RHEL 8 and later, and systems using GRUB2 (s390x uses zipl)
85+
loggerinst.info("Skipped. Only relevant to RHEL 8 and newer.")
8486
return
8587

86-
loggerinst.info("Fixing GRUB boot loader entries.")
87-
8888
machine_id = utils.get_file_content("/etc/machine-id").strip()
8989
boot_entries = glob.glob("/boot/loader/entries/*.conf")
9090
for entry in boot_entries:
91-
# The boot loader entries in /boot/loader/entries/<machine-id>-<kernel-version>.conf
91+
# The bootloader entries in /boot/loader/entries/<machine-id>-<kernel-version>.conf
9292
if machine_id not in os.path.basename(entry):
93-
loggerinst.debug("Removing boot entry {}".format(entry))
93+
loggerinst.debug("Removing boot entry {}.".format(entry))
9494
os.remove(entry)
9595

9696
# Removing a boot entry that used to be the default makes grubby to choose a different entry as default,
@@ -99,24 +99,24 @@ def run(self):
9999
if ret_code:
100100
# Not setting the default entry shouldn't be a deal breaker and the reason to stop the conversions,
101101
# grub should pick one entry in any case.
102-
description = "Couldn't get the default GRUB2 boot loader entry:\n{}".format(output)
102+
description = "Couldn't get the default GRUB2 bootloader entry:\n{}".format(output)
103103
loggerinst.warning(description)
104104
self.add_message(
105105
level="WARNING",
106106
id="UNABLE_TO_GET_GRUB2_BOOT_LOADER_ENTRY",
107-
title="Unable to get the GRUB2 boot loader entry",
107+
title="Unable to get the GRUB2 bootloader entry",
108108
description=description,
109109
)
110110
return
111-
loggerinst.debug("Setting RHEL kernel {} as the default boot loader entry.".format(output.strip()))
111+
loggerinst.debug("Setting RHEL kernel {} as the default bootloader entry.".format(output.strip()))
112112
output, ret_code = utils.run_subprocess(["/usr/sbin/grubby", "--set-default", output.strip()])
113113
if ret_code:
114-
description = "Couldn't set the default GRUB2 boot loader entry:\n{}".format(output)
114+
description = "Couldn't set the default GRUB2 bootloader entry:\n{}".format(output)
115115
loggerinst.warning(description)
116116
self.add_message(
117117
level="WARNING",
118118
id="UNABLE_TO_SET_GRUB2_BOOT_LOADER_ENTRY",
119-
title="Unable to set the GRUB2 boot loader entry",
119+
title="Unable to set the GRUB2 bootloader entry",
120120
description=description,
121121
)
122122

@@ -134,7 +134,7 @@ def run(self):
134134
"""
135135
super(FixDefaultKernel, self).run()
136136

137-
loggerinst.info("Checking for incorrect boot kernel")
137+
loggerinst.task("Check for default boot kernel in /etc/sysconfig/kernel")
138138
kernel_sys_cfg = utils.get_file_content("/etc/sysconfig/kernel")
139139

140140
possible_kernels = ["kernel-uek", "kernel-plus"]
@@ -143,22 +143,29 @@ def run(self):
143143
None,
144144
)
145145
if kernel_to_change:
146-
description = "Detected leftover boot kernel, changing to RHEL kernel"
147-
loggerinst.warning(description)
146+
diagnosis = "Detected default boot kernel {} in /etc/sysconfig/kernel.".format(kernel_to_change)
147+
# need to change to "kernel" in rhel7 and "kernel-core" in rhel8
148+
new_kernel_str = "DEFAULTKERNEL=" + ("kernel" if system_info.version.major == 7 else "kernel-core")
149+
loggerinst.warning(diagnosis)
148150
self.add_message(
149151
level="WARNING",
150152
id="LEFTOVER_BOOT_KERNEL_DETECTED",
151-
title="Leftover boot kernel detected",
152-
description=description,
153+
title="Leftover default boot kernel detected",
154+
diagnosis=diagnosis,
155+
description="Some systems have the default boot kernel in /etc/sysconfig/kernel set to a distribution"
156+
" specific kernel even after such a kernel is uninstalled. We have changed it to {}.".format(
157+
new_kernel_str
158+
),
153159
)
154-
# need to change to "kernel" in rhel7 and "kernel-core" in rhel8
155-
new_kernel_str = "DEFAULTKERNEL=" + ("kernel" if system_info.version.major == 7 else "kernel-core")
156-
157160
kernel_sys_cfg = kernel_sys_cfg.replace("DEFAULTKERNEL=" + kernel_to_change, new_kernel_str)
158161
utils.store_content_to_file("/etc/sysconfig/kernel", kernel_sys_cfg)
159-
loggerinst.info("Boot kernel {} was changed to {}".format(kernel_to_change, new_kernel_str))
162+
loggerinst.info(
163+
"Default boot kernel {} was changed to {} in /etc/sysconfig/kernel.".format(
164+
kernel_to_change, new_kernel_str
165+
)
166+
)
160167
else:
161-
loggerinst.debug("Boot kernel validated.")
168+
loggerinst.debug("The default boot kernel is correct.")
162169

163170

164171
class KernelPkgsInstall(actions.Action):
@@ -169,18 +176,20 @@ def run(self):
169176
"""Remove non-RHEL kernels."""
170177
super(KernelPkgsInstall, self).run()
171178

179+
loggerinst.task("Remove non-RHEL kernels")
180+
172181
kernel_pkgs_to_install = self.remove_non_rhel_kernels()
173182
if kernel_pkgs_to_install:
174183
self.install_additional_rhel_kernel_pkgs(kernel_pkgs_to_install)
175184

176185
def remove_non_rhel_kernels(self):
177-
loggerinst.info("Searching for non-RHEL kernels ...")
186+
loggerinst.info("Searching for non-RHEL kernels.")
178187
non_rhel_kernels = pkghandler.get_installed_pkgs_w_different_key_id(system_info.key_ids_rhel, "kernel*")
179188
if not non_rhel_kernels:
180189
loggerinst.info("None found.")
181190
return None
182191

183-
loggerinst.info("Removing non-RHEL kernels\n")
192+
loggerinst.info("Removing detected non-RHEL kernels.\n")
184193
pkghandler.print_pkg_info(non_rhel_kernels)
185194
pkgs_to_remove = [pkghandler.get_pkg_nvra(pkg) for pkg in non_rhel_kernels]
186195
utils.remove_pkgs(pkgs_to_remove)
@@ -198,7 +207,7 @@ def install_additional_rhel_kernel_pkgs(self, additional_pkgs):
198207
pkg_names = [p.nevra.name.replace(ol_kernel_ext, "", 1) for p in additional_pkgs]
199208
for name in set(pkg_names):
200209
if name != "kernel":
201-
loggerinst.info("Installing RHEL {}".format(name))
210+
loggerinst.info("Installing RHEL {}.".format(name))
202211
pkgmanager.call_yum_cmd("install", args=[name])
203212

204213

@@ -217,4 +226,5 @@ def run(self):
217226
"""
218227
super(UpdateKernel, self).run()
219228

229+
loggerinst.task("Update RHEL kernel")
220230
pkghandler.update_rhel_kernel()

convert2rhel/actions/conversion/set_efi_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def run(self):
169169
)
170170
continue
171171

172-
logger.info("Moving '{}' to '{}'".format(src_file, dst_file))
172+
logger.info("Moving '{}' to '{}'.".format(src_file, dst_file))
173173

174174
try:
175175
shutil.move(src_file, dst_file)

convert2rhel/actions/post_conversion/hostmetering.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def run(self):
6969
self.add_message(
7070
level="WARNING",
7171
id="INSTALL_HOST_METERING_FAILURE",
72-
title="Failed to install host metering package.",
73-
description="When installing host metering package an error occurred meaning we can't"
72+
title="Failed to install the host-metering package",
73+
description="When installing the host-metering package an error occurred meaning we can't"
7474
" enable host metering on the system.",
7575
diagnosis="`yum install host-metering` command returned {ret_install} with message {output}".format(
7676
ret_install=ret_install, output=output
@@ -89,9 +89,9 @@ def run(self):
8989
self.add_message(
9090
level="WARNING",
9191
id="CONFIGURE_HOST_METERING_FAILURE",
92-
title="Failed to enable and start host metering service.",
92+
title="Failed to enable and start the host metering service",
9393
description="The host metering service failed to start"
94-
" successfully and won't be able to keep track.",
94+
" successfully and won't be able to report on the use of the system for the billing purposes.",
9595
diagnosis="Command {command} failed with {error_message}".format(
9696
command=command, error_message=error_message
9797
),
@@ -109,7 +109,7 @@ def run(self):
109109
self.set_result(
110110
level="ERROR",
111111
id="HOST_METERING_NOT_RUNNING",
112-
title="Host metering service is not running.",
112+
title="Host metering service is not running",
113113
description="host-metering.service is not running.",
114114
remediations="You can try to start the service manually"
115115
" by running following command:\n"
@@ -126,7 +126,7 @@ def _check_host_metering_configuration(self):
126126
:rtype: bool
127127
"""
128128
if tool_opts.configure_host_metering is None:
129-
logger.debug("You have not enabled configuration of host metering. Skipping it.")
129+
logger.info("You have not enabled configuration of host metering. Skipping it.")
130130
return False
131131

132132
if tool_opts.configure_host_metering not in ("force", "auto"):
@@ -152,19 +152,22 @@ def _check_host_metering_configuration(self):
152152
if tool_opts.configure_host_metering == "force":
153153
logger.warning(
154154
"You've set the host metering setting to 'force'."
155-
" Please note that this option is mainly used for testing and will configure host-metering unconditionally. "
156-
" For generic usage please use the 'auto' option."
155+
" Note that this option is mainly used for testing and will configure host-metering unconditionally. "
156+
" For generic usage use the 'auto' option."
157157
)
158158
self.add_message(
159159
level="WARNING",
160160
id="FORCED_CONFIGURE_HOST_METERING",
161161
title="Configuration of host metering set to 'force'",
162-
description="Please note that this option is mainly used for testing and"
162+
description="Note that this option is mainly used for testing and"
163163
" will configure host-metering unconditionally."
164-
" For generic usage please use the 'auto' option.",
164+
" For generic usage use the 'auto' option.",
165165
)
166166
elif tool_opts.configure_host_metering == "auto":
167-
logger.debug("Automatic detection of host hyperscaler and configuration.")
167+
logger.debug(
168+
"Configuration of host metering set to 'auto' - host-metering will be enabled based on"
169+
" a detected hyperscaler."
170+
)
168171

169172
return True
170173

convert2rhel/actions/post_conversion/modified_rpm_files_diff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run(self):
4646
self.add_message(
4747
level="INFO",
4848
id="SKIPPED_MODIFIED_RPM_FILES_DIFF",
49-
title="Skipped comparison of 'rpm -Va' output from before and after the conversion.",
49+
title="Skipped comparison of 'rpm -Va' output from before and after the conversion",
5050
description="Comparison of 'rpm -Va' output was not performed due to missing output "
5151
"of the 'rpm -Va' run before the conversion.",
5252
diagnosis="This is caused mainly by using '--no-rpm-va' argument for convert2rhel.",
@@ -76,8 +76,8 @@ def run(self):
7676
self.add_message(
7777
level="INFO",
7878
id="FOUND_MODIFIED_RPM_FILES",
79-
title="Modified rpm files from before and after the conversion were found.",
80-
description="Comparison of modified rpm files from before and after " "the conversion: \n{}".format(
79+
title="Modified rpm files from before and after the conversion were found",
80+
description="Comparison of modified rpm files from before and after the conversion: \n{}".format(
8181
modified_rpm_files_diff
8282
),
8383
)

convert2rhel/actions/post_conversion/remove_tmp_dir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run(self):
4545

4646
try:
4747
shutil.rmtree(self.tmp_dir)
48-
loggerinst.info("Temporary folder {} removed".format(self.tmp_dir))
48+
loggerinst.info("Temporary folder {} removed.".format(self.tmp_dir))
4949
except OSError as exc:
5050
# We want run() to be idempotent, so do nothing silently if
5151
# the path doesn't exist.
@@ -61,6 +61,6 @@ def run(self):
6161
self.add_message(
6262
level="WARNING",
6363
id="UNSUCCESSFUL_REMOVE_TMP_DIR",
64-
title="Temporary folder {tmp_dir} wasn't removed.".format(tmp_dir=self.tmp_dir),
64+
title="Temporary folder {tmp_dir} wasn't removed".format(tmp_dir=self.tmp_dir),
6565
description=warning_message,
6666
)

convert2rhel/actions/post_conversion/update_grub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def run(self):
7777
level="ERROR",
7878
id="FAILED_TO_IDENTIFY_GRUB2_BLOCK_DEVICE",
7979
title="Failed to identify GRUB2 block device",
80-
description="The block device could not be identified, please look at the diagnosis "
80+
description="The block device could not be identified. Look at the diagnosis "
8181
"for more information.",
8282
diagnosis=str(e),
8383
)

convert2rhel/actions/pre_ponr_changes/backup_system.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class BackupRedhatRelease(actions.Action):
5151
id = "BACKUP_REDHAT_RELEASE"
5252

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

5757
super(BackupRedhatRelease, self).run()
5858

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

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

8484
super(BackupRepository, self).run()
8585

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

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

110110
super(BackupYumVariables, self).run()
111111

@@ -146,7 +146,7 @@ def run(self):
146146
"""Backup changed package files"""
147147
super(BackupPackageFiles, self).run()
148148

149-
logger.task("Backup package files")
149+
logger.task("Back up package files")
150150

151151
package_files_changes = self._get_changed_package_files()
152152

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

207205
lines = output.strip().split("\n")
208206
for line in lines:
@@ -220,7 +218,7 @@ def _parse_line(self, line):
220218
if not match: # line not matching the regex
221219
if line.strip() != "":
222220
# Line is not empty string
223-
logger.debug("Skipping invalid output {}".format(line))
221+
logger.debug("Skipping invalid output: {}".format(line))
224222
return {"status": None, "file_type": None, "path": None}
225223

226224
line = line.split()

0 commit comments

Comments
 (0)