Skip to content

Commit b6adb2a

Browse files
committed
Tell user 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.
1 parent 5be973f commit b6adb2a

File tree

4 files changed

+47
-43
lines changed

4 files changed

+47
-43
lines changed

convert2rhel/actions/post_conversion/hostmetering.py

+26-24
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@
2828

2929

3030
class ConfigureHostMetering(actions.Action):
31-
"""Configure host metering on a machine if it's needed.
32-
33-
env_var: str
34-
Content of CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.
35-
"""
31+
"""Configure host metering on a machine if it's needed."""
3632

3733
id = "CONFIGURE_HOST_METERING_IF_NEEDED"
3834

3935
def run(self):
4036
"""
41-
Decide whether to install, enable and start host-metering on the system based on the
42-
CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.
37+
Decide whether to install, enable and start host-metering on the system based on the setting of
38+
'configure_host_metering' in /etc/convert2rhel.ini.
4339
44-
Behavior can be controlled CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable:
40+
The behavior can be controlled via the 'configure_host_metering' as follows:
4541
- "auto": host-metering will be configured based on the above conditions
4642
- "force": forces configuration of host-metering (e.g., even if not running on a hyperscaler)
4743
- any other value: Will be ignored and host metering will not be configured.
@@ -53,7 +49,7 @@ def run(self):
5349
super(ConfigureHostMetering, self).run()
5450

5551
warn_deprecated_env("CONVERT2RHEL_CONFIGURE_HOST_METERING")
56-
if not self._check_env_var():
52+
if not self._check_host_metering_configuration():
5753
return False
5854

5955
if system_info.version.major != 7 and tool_opts.configure_host_metering == "auto":
@@ -62,7 +58,7 @@ def run(self):
6258
level="INFO",
6359
id="CONFIGURE_HOST_METERING_SKIP",
6460
title="Did not perform host metering configuration.",
65-
description="Host metering is supportted only for RHEL 7.",
61+
description="Host metering is supported only for RHEL 7.",
6662
)
6763
return False
6864

@@ -134,52 +130,58 @@ def run(self):
134130

135131
return service_running
136132

137-
def _check_env_var(self):
138-
"""Check if the env var is set and if it has the right content. If the
139-
content is auto|force, the hostmetering should be configued on the system.
133+
def _check_host_metering_configuration(self):
134+
"""Check if host metering has been configured by the user and if the configuration option has the right value.
135+
If the value is auto|force, the host metering should be configured on the system.
140136
141137
:return: Return True if the value is equal to auto|force, otherwise False
142138
:rtype: bool
143139
"""
144140
if tool_opts.configure_host_metering is None:
145-
logger.debug("CONVERT2RHEL_CONFIGURE_HOST_METERING was not set. Skipping it.")
141+
logger.debug("Configuration of host metering has not been enabled. Skipping it.")
146142
self.add_message(
147143
level="INFO",
148144
id="CONFIGURE_HOST_METERING_SKIP",
149145
title="Did not perform host metering configuration.",
150-
description="CONVERT2RHEL_CONFIGURE_HOST_METERING was not set.",
146+
description="Configuration of host metering has been skipped.",
147+
diagnosis="We haven't detected 'configure_host_metering' in the convert2rhel.ini config file nor" \
148+
" the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.",
151149
)
152150
return False
153151

154152
if tool_opts.configure_host_metering not in ("force", "auto"):
155-
logger.debug("Value for environment variable not recognized: {}".format(tool_opts.configure_host_metering))
153+
logger.debug("Unexpected value of 'configure_host_metering' in convert2rhel.ini or the"
154+
" CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: {}"
155+
.format(tool_opts.configure_host_metering))
156156
self.add_message(
157157
level="WARNING",
158158
id="UNRECOGNIZED_OPTION_CONFIGURE_HOST_METERING",
159-
title="Unrecognized option in CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.",
160-
description="Environment variable {env_var} not recognized.".format(
161-
env_var=tool_opts.configure_host_metering
162-
),
163-
remediations="Set the option to `auto` value if you want to configure host metering.",
159+
title="Unexpected value of the host metering setting.",
160+
diagnosis="Unexpected value of 'configure_host_metering' in convert2rhel.ini or the" \
161+
" CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: {}"
162+
.format(tool_opts.configure_host_metering),
163+
description="Host metering will not be configured.",
164+
remediations="Set the option to 'auto' or 'force' if you want to configure host metering.",
164165
)
165166
return False
166167

167168
if tool_opts.configure_host_metering == "force":
168169
logger.warning(
169-
"The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable."
170+
"You've set the host metering setting to 'force'."
170171
" Please note that this option is mainly used for testing and will configure host-metering unconditionally. "
171172
" For generic usage please use the 'auto' option."
172173
)
173174
self.add_message(
174175
level="WARNING",
175176
id="FORCED_CONFIGURE_HOST_METERING",
176-
title="The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.",
177+
title="Configuration of host metering set to 'force'",
177178
description="Please note that this option is mainly used for testing and"
178179
" will configure host-metering unconditionally."
179180
" For generic usage please use the 'auto' option.",
180181
)
181182
elif tool_opts.configure_host_metering == "auto":
182-
logger.debug("Automatic detection of host hyperscaler and configuration.")
183+
logger.debug("Configuration of host metering set to 'auto' - host-metering will be enabled based on"
184+
" a detected hyperscaler.")
183185

184186
return True
185187

convert2rhel/actions/pre_ponr_changes/backup_system.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ def _get_changed_package_files(self):
192192
except IOError as err:
193193
warn_deprecated_env("CONVERT2RHEL_INCOMPLETE_ROLLBACK")
194194
if tool_opts.incomplete_rollback:
195-
logger.debug("Skipping backup of the package files. CONVERT2RHEL_INCOMPLETE_ROLLBACK detected.")
195+
logger.debug("You have set the incomplete rollback inhibitor override - skipping backup of"
196+
" the package files.")
196197
# Return empty list results in no backup of the files
197198
return data
198199
else:

convert2rhel/actions/pre_ponr_changes/kernel_modules.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,21 @@ def run(self):
247247
rhel_supported_kmods = self._get_rhel_supported_kmods()
248248
unsupported_kmods = self._get_unsupported_kmods(host_kmods, rhel_supported_kmods)
249249

250-
# Check if we have the environment variable set, if we do, send a
250+
# Check if the user has specified that they allow unavailable kmods and if so, print a
251251
# warning and return.
252252
warn_deprecated_env("CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS")
253253
if tool_opts.allow_unavailable_kmods:
254254
logger.warning(
255-
"Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable."
256-
" We will continue the conversion with the following kernel modules unavailable in RHEL:\n"
255+
"You have set the option to allow unavailable kernel modules."
256+
" The conversion will continue with the following kernel modules unavailable in RHEL:\n"
257257
"{kmods}\n".format(kmods="\n".join(unsupported_kmods))
258258
)
259259
self.add_message(
260260
level="WARNING",
261261
id="ALLOW_UNAVAILABLE_KERNEL_MODULES",
262-
title="Did not perform the ensure kernel modules compatibility check",
263-
description="Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable.",
264-
diagnosis="We will continue the conversion with the following kernel modules unavailable in RHEL:\n"
262+
title="Ignoring the check ensuring kernel module availability in RHEL",
263+
diagnosis="You have set the option to allow unavailable kernel modules.",
264+
description="We will continue the conversion with the following kernel modules unavailable in RHEL:\n"
265265
"{kmods}\n".format(kmods="\n".join(unsupported_kmods)),
266266
)
267267
return
@@ -280,8 +280,8 @@ def run(self):
280280
"message persists, you can prevent the modules from loading by following {0} and rerun convert2rhel.\n"
281281
"Keeping them loaded could cause the system to malfunction after the conversion as they might not work "
282282
"properly with the RHEL kernel.\n"
283-
"To circumvent this check and accept the risk you can set environment variable "
284-
"'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS=1'.".format(LINK_PREVENT_KMODS_FROM_LOADING),
283+
"To circumvent this check and accept the risk, set the allow_unavailable_kmods inhibitor override in the"
284+
"/etc/convert2rhel.ini config file to true.".format(LINK_PREVENT_KMODS_FROM_LOADING),
285285
)
286286
return
287287

convert2rhel/actions/system_checks/is_loaded_kernel_latest.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ def run(self):
6969
warn_deprecated_env("CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK")
7070
if tool_opts.skip_kernel_currency_check:
7171
logger.warning(
72-
"Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip "
73-
"the {} comparison.\n"
72+
"You have set the option to skip the kernel currency check - we will skip the {} comparison.\n"
7473
"Beware, this could leave your system in a broken state.".format(package_to_check)
7574
)
7675

7776
self.add_message(
7877
level="WARNING",
7978
id="UNSUPPORTED_SKIP_KERNEL_CURRENCY_CHECK_DETECTED",
8079
title="Did not perform the kernel currency check",
81-
description=(
82-
"Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip "
80+
description="Not checking if the loaded kernel is of the latest available version could leave your"
81+
" system in a broken state",
82+
diagnosis=(
83+
"You have set the option to skip the kernel currency check - we will skip "
8384
"the {} comparison.\n"
8485
"Beware, this could leave your system in a broken state.".format(package_to_check)
8586
),
@@ -98,15 +99,15 @@ def run(self):
9899
logger.debug("Got the following output: %s", repoquery_output)
99100
logger.warning(
100101
"Couldn't fetch the list of the most recent kernels available in "
101-
"the repositories. Did not perform the loaded kernel check."
102+
"the repositories. Did not perform the loaded kernel currency check."
102103
)
103104
self.add_message(
104105
level="WARNING",
105106
id="UNABLE_TO_FETCH_RECENT_KERNELS",
106107
title="Unable to fetch recent kernels",
107108
description=(
108109
"Couldn't fetch the list of the most recent kernels available in "
109-
"the repositories. Did not perform the loaded kernel check."
110+
"the repositories. Did not perform the loaded kernel currency check."
110111
),
111112
)
112113
return
@@ -142,8 +143,8 @@ def run(self):
142143
),
143144
remediations=(
144145
"Please, check if you have any vendor repositories enabled to proceed with the conversion.\n"
145-
"If you wish to disregard this message, set the environment variable "
146-
"'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1."
146+
"If you wish to disregard this message, set the skip_kernel_currency_check inhibitor override in"
147+
" the /etc/convert2rhel.ini config file to true."
147148
),
148149
)
149150
return
@@ -184,8 +185,8 @@ def run(self):
184185
"To proceed with the conversion, update the kernel version by executing the following step:\n\n"
185186
"1. yum install {}-{} -y\n"
186187
"2. reboot\n"
187-
"If you wish to ignore this message, set the environment variable "
188-
"'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1.".format(package_to_check, latest_kernel)
188+
"If you wish to ignore this message, set the skip_kernel_currency_check inhibitor override in"
189+
" the /etc/convert2rhel.ini config file to true.".format(package_to_check, latest_kernel)
189190
),
190191
)
191192
return

0 commit comments

Comments
 (0)