Skip to content

Commit 657a354

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 4eb0ab6 commit 657a354

85 files changed

Lines changed: 465 additions & 384 deletions

File tree

Some content is hidden

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

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: 34 additions & 24 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

@@ -165,7 +165,7 @@ def run(self):
165165
utils.store_content_to_file(self.KERNEL_SYSCONFIG_PATH, content)
166166
return
167167

168-
loggerinst.info("Checking for incorrect boot kernel")
168+
loggerinst.task("Check for default boot kernel in /etc/sysconfig/kernel")
169169
kernel_sys_cfg = utils.get_file_content(self.KERNEL_SYSCONFIG_PATH)
170170

171171
possible_kernels = ["kernel-uek", "kernel-plus"]
@@ -174,21 +174,28 @@ def run(self):
174174
None,
175175
)
176176
if kernel_to_change:
177-
description = "Detected leftover boot kernel, changing to RHEL kernel"
178-
loggerinst.warning(description)
177+
diagnosis = "Detected default boot kernel {} in /etc/sysconfig/kernel.".format(kernel_to_change)
178+
new_kernel_str = "DEFAULTKERNEL=" + default_kernel
179+
loggerinst.warning(diagnosis)
179180
self.add_message(
180181
level="WARNING",
181182
id="LEFTOVER_BOOT_KERNEL_DETECTED",
182-
title="Leftover boot kernel detected",
183-
description=description,
183+
title="Leftover default boot kernel detected",
184+
diagnosis=diagnosis,
185+
description="Some systems have the default boot kernel in /etc/sysconfig/kernel set to a distribution"
186+
" specific kernel even after such a kernel is uninstalled. We have changed it to {}.".format(
187+
new_kernel_str
188+
),
184189
)
185-
new_kernel_str = "DEFAULTKERNEL=" + default_kernel
186-
187190
kernel_sys_cfg = kernel_sys_cfg.replace("DEFAULTKERNEL=" + kernel_to_change, new_kernel_str)
188191
utils.store_content_to_file(self.KERNEL_SYSCONFIG_PATH, kernel_sys_cfg)
189-
loggerinst.info("Boot kernel {} was changed to {}".format(kernel_to_change, new_kernel_str))
192+
loggerinst.info(
193+
"Default boot kernel {} was changed to {} in /etc/sysconfig/kernel.".format(
194+
kernel_to_change, new_kernel_str
195+
)
196+
)
190197
else:
191-
loggerinst.debug("Boot kernel validated.")
198+
loggerinst.debug("The default boot kernel is correct.")
192199

193200

194201
class KernelPkgsInstall(actions.Action):
@@ -199,18 +206,20 @@ def run(self):
199206
"""Remove non-RHEL kernels."""
200207
super(KernelPkgsInstall, self).run()
201208

209+
loggerinst.task("Remove non-RHEL kernels")
210+
202211
kernel_pkgs_to_install = self.remove_non_rhel_kernels()
203212
if kernel_pkgs_to_install:
204213
self.install_additional_rhel_kernel_pkgs(kernel_pkgs_to_install)
205214

206215
def remove_non_rhel_kernels(self):
207-
loggerinst.info("Searching for non-RHEL kernels ...")
216+
loggerinst.info("Searching for non-RHEL kernels.")
208217
non_rhel_kernels = pkghandler.get_installed_pkgs_w_different_key_id(system_info.key_ids_rhel, "kernel*")
209218
if not non_rhel_kernels:
210219
loggerinst.info("None found.")
211220
return None
212221

213-
loggerinst.info("Removing non-RHEL kernels\n")
222+
loggerinst.info("Removing detected non-RHEL kernels.\n")
214223
pkghandler.print_pkg_info(non_rhel_kernels)
215224
pkgs_to_remove = [pkghandler.get_pkg_nvra(pkg) for pkg in non_rhel_kernels]
216225
utils.remove_pkgs(pkgs_to_remove)
@@ -228,7 +237,7 @@ def install_additional_rhel_kernel_pkgs(self, additional_pkgs):
228237
pkg_names = [p.nevra.name.replace(ol_kernel_ext, "", 1) for p in additional_pkgs]
229238
for name in set(pkg_names):
230239
if name != "kernel":
231-
loggerinst.info("Installing RHEL {}".format(name))
240+
loggerinst.info("Installing RHEL {}.".format(name))
232241
pkgmanager.call_yum_cmd("install", args=[name])
233242

234243

@@ -247,4 +256,5 @@ def run(self):
247256
"""
248257
super(UpdateKernel, self).run()
249258

259+
loggerinst.task("Update RHEL kernel")
250260
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
@@ -74,8 +74,8 @@ def run(self):
7474
self.add_message(
7575
level="WARNING",
7676
id="INSTALL_HOST_METERING_FAILURE",
77-
title="Failed to install host metering package.",
78-
description="When installing host metering package an error occurred meaning we can't"
77+
title="Failed to install the host-metering package",
78+
description="When installing the host-metering package an error occurred meaning we can't"
7979
" enable host metering on the system.",
8080
diagnosis="`yum install host-metering` command returned {ret_install} with message {output}".format(
8181
ret_install=ret_install, output=output
@@ -94,9 +94,9 @@ def run(self):
9494
self.add_message(
9595
level="WARNING",
9696
id="CONFIGURE_HOST_METERING_FAILURE",
97-
title="Failed to enable and start host metering service.",
97+
title="Failed to enable and start the host metering service",
9898
description="The host metering service failed to start"
99-
" successfully and won't be able to keep track.",
99+
" successfully and won't be able to report on the use of the system for the billing purposes.",
100100
diagnosis="Command {command} failed with {error_message}".format(
101101
command=command, error_message=error_message
102102
),
@@ -114,7 +114,7 @@ def run(self):
114114
self.set_result(
115115
level="ERROR",
116116
id="HOST_METERING_NOT_RUNNING",
117-
title="Host metering service is not running.",
117+
title="Host metering service is not running",
118118
description="host-metering.service is not running.",
119119
remediations="You can try to start the service manually"
120120
" by running following command:\n"
@@ -131,7 +131,7 @@ def _check_host_metering_configuration(self):
131131
:rtype: bool
132132
"""
133133
if tool_opts.configure_host_metering is None:
134-
logger.debug("You have not enabled configuration of host metering. Skipping it.")
134+
logger.info("You have not enabled configuration of host metering. Skipping it.")
135135
return False
136136

137137
if tool_opts.configure_host_metering not in ("force", "auto"):
@@ -157,19 +157,22 @@ def _check_host_metering_configuration(self):
157157
if tool_opts.configure_host_metering == "force":
158158
logger.warning(
159159
"You've set the host metering setting to 'force'."
160-
" Please note that this option is mainly used for testing and will configure host-metering unconditionally. "
161-
" For generic usage please use the 'auto' option."
160+
" Note that this option is mainly used for testing and will configure host-metering unconditionally. "
161+
" For generic usage use the 'auto' option."
162162
)
163163
self.add_message(
164164
level="WARNING",
165165
id="FORCED_CONFIGURE_HOST_METERING",
166166
title="Configuration of host metering set to 'force'",
167-
description="Please note that this option is mainly used for testing and"
167+
description="Note that this option is mainly used for testing and"
168168
" will configure host-metering unconditionally."
169-
" For generic usage please use the 'auto' option.",
169+
" For generic usage use the 'auto' option.",
170170
)
171171
elif tool_opts.configure_host_metering == "auto":
172-
logger.debug("Automatic detection of host hyperscaler and configuration.")
172+
logger.debug(
173+
"Configuration of host metering set to 'auto' - host-metering will be enabled based on"
174+
" a detected hyperscaler."
175+
)
173176

174177
return True
175178

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
@@ -132,7 +132,7 @@ def run(self):
132132
level="ERROR",
133133
id="FAILED_TO_IDENTIFY_GRUB2_BLOCK_DEVICE",
134134
title="Failed to identify GRUB2 block device",
135-
description="The block device could not be identified, please look at the diagnosis "
135+
description="The block device could not be identified. Look at the diagnosis "
136136
"for more information.",
137137
diagnosis=str(e),
138138
)

convert2rhel/actions/pre_ponr_changes/backup_system.py

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

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

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

@@ -78,7 +78,7 @@ class BackupRepository(actions.Action):
7878

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

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

@@ -111,7 +111,7 @@ def run(self):
111111
"""Backup changed package files"""
112112
super(BackupPackageFiles, self).run()
113113

114-
logger.task("Backup package files")
114+
logger.task("Back up package files")
115115

116116
package_files_changes = self._get_changed_package_files()
117117

@@ -143,7 +143,6 @@ def _get_changed_package_files(self):
143143
"""Get the output from rpm -Va command from during resolving system info
144144
to get changes made to package files.
145145
146-
147146
:return dict: Return them as a list of dict, for example:
148147
[{"status":"S5T", "file_type":"c", "path":"/etc/yum.repos.d/CentOS-Linux-AppStream.repo"}]
149148
"""
@@ -164,10 +163,9 @@ def _get_changed_package_files(self):
164163
# Return empty list results in no backup of the files
165164
return data
166165
else:
167-
# The file should be there
168-
# If missing conversion is in unknown state
166+
# The file should be there. If missing, the conversion is in an unknown state.
169167
logger.warning("Error({}): {}".format(err.errno, err.strerror))
170-
logger.critical("Missing file {rpm_va_output} in it's location".format(rpm_va_output=path))
168+
logger.critical("The file {rpm_va_output} is missing.".format(rpm_va_output=path))
171169

172170
lines = output.strip().split("\n")
173171
for line in lines:
@@ -185,7 +183,7 @@ def _parse_line(self, line):
185183
if not match: # line not matching the regex
186184
if line.strip() != "":
187185
# Line is not empty string
188-
logger.debug("Skipping invalid output {}".format(line))
186+
logger.debug("Skipping invalid output: {}".format(line))
189187
return {"status": None, "file_type": None, "path": None}
190188

191189
line = line.split()

0 commit comments

Comments
 (0)