Skip to content

Commit

Permalink
Breaking change: Rename incomplete rollback envvar
Browse files Browse the repository at this point in the history
We are moving away from using the word UNSUPPORTED in environment
variables as it is confusing and not very descriptive of what is
unsupported. Since this relates to the tool itself not supporting it in
a predictable way, we are renaming mentions of the word unsupported.

This change has to do with renaming
CONVERT2RHEL_UNSUPPORTED INCOMPLETE_ROLLBACK
to
CONVERT2RHEL_INCOMPLETE_ROLLBACK

CONVERT2RHEL_INCOMPLETE_ROLLBACK means that we can garantee a rollback
will be successful on a potential failure and user would have to specify
the environment variable themselves to understand this to not blame the
tool.

This change does not do anything else and no backwards compatibility is
considered as it is intended to be changed in a major version change.

Related
RHELC-1430
  • Loading branch information
Venefilyn committed Mar 22, 2024
1 parent 3eb7e06 commit 061bc66
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion convert2rhel/actions/pre_ponr_changes/backup_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _get_changed_package_files(self):
output = f.read()
# Catch the IOError due Python 2 compatibility
except IOError as err:
if os.environ.get("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", None):
if os.environ.get("CONVERT2RHEL_INCOMPLETE_ROLLBACK", None):
loggerinst.debug("Skipping backup of the package files. CONVERT2RHEL_INCOMPLETE_ROLLBACK detected.")
# Return empty list results in no backup of the files
return data
Expand Down
6 changes: 3 additions & 3 deletions convert2rhel/toolopts.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _register_options(self):
" stored in log files %s and %s. 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_UNSUPPORTED_INCOMPLETE_ROLLBACK"
" The environment variable CONVERT2RHEL_INCOMPLETE_ROLLBACK"
" needs to be set to 1 to use this argument." % (PRE_RPM_VA_LOG_FILENAME, POST_RPM_VA_LOG_FILENAME),
)
self._shared_options_parser.add_argument(
Expand Down Expand Up @@ -369,13 +369,13 @@ def _process_cli_options(self):
" in the analysis mode is essential for a complete rollback to the original"
" system state at the end of the analysis."
)
elif os.getenv("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", None):
elif os.getenv("CONVERT2RHEL_INCOMPLETE_ROLLBACK", None):
tool_opts.no_rpm_va = True
else:
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_UNSUPPORTED_INCOMPLETE_ROLLBACK=1 environment"
" incomplete rollback, set the CONVERT2RHEL_INCOMPLETE_ROLLBACK=1 environment"
" variable. Otherwise, remove the --no-rpm-va option."
)
loggerinst.critical(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ def test_get_changed_package_files_missing(self, caplog, message, env_var, tmpdi
monkeypatch.setattr(backup_system, "LOG_DIR", str(tmpdir))

if env_var:
os.environ["CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK"] = "1"
os.environ["CONVERT2RHEL_INCOMPLETE_ROLLBACK"] = "1"
else:
# Unset the variable
os.environ.pop("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", None)
os.environ.pop("CONVERT2RHEL_INCOMPLETE_ROLLBACK", None)

backup_package_file = backup_system.BackupPackageFiles()

Expand Down
4 changes: 2 additions & 2 deletions convert2rhel/unit_tests/toolopts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,15 @@ def test_should_subscribe(username, password, organization, activation_key, no_r
["--no-rpm-va"],
False,
False,
"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_UNSUPPORTED_INCOMPLETE_ROLLBACK=1 environment variable. Otherwise, remove the --no-rpm-va option.",
"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.",
),
(["--no-rpm-va"], True, True, ""),
),
)
def test_setting_no_rpm_va(argv, env_var, expected, message, monkeypatch, global_tool_opts, caplog):
monkeypatch.setattr(sys, "argv", mock_cli_arguments(argv))
if env_var:
monkeypatch.setenv("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", "1")
monkeypatch.setenv("CONVERT2RHEL_INCOMPLETE_ROLLBACK", "1")

try:
convert2rhel.toolopts.CLI()
Expand Down
8 changes: 4 additions & 4 deletions convert2rhel/unit_tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def test_download_pkg_failed_during_analysis_download_exit(self, monkeypatch):
monkeypatch.setattr(system_info, "releasever", "7Server")
monkeypatch.setattr(system_info, "version", systeminfo.Version(7, 0))
monkeypatch.setattr(utils, "run_cmd_in_pty", RunCmdInPtyMocked(return_code=1))
monkeypatch.setattr(os, "environ", {"CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK": "1"})
monkeypatch.setattr(os, "environ", {"CONVERT2RHEL_INCOMPLETE_ROLLBACK": "1"})
monkeypatch.setattr(toolopts.tool_opts, "activity", "analysis")

with pytest.raises(SystemExit):
Expand All @@ -533,7 +533,7 @@ def test_download_pkg_failed_download_overridden(self, monkeypatch):
monkeypatch.setattr(system_info, "releasever", "7Server")
monkeypatch.setattr(system_info, "version", systeminfo.Version(7, 0))
monkeypatch.setattr(utils, "run_cmd_in_pty", RunCmdInPtyMocked(return_code=1))
monkeypatch.setattr(os, "environ", {"CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK": "1"})
monkeypatch.setattr(os, "environ", {"CONVERT2RHEL_INCOMPLETE_ROLLBACK": "1"})
monkeypatch.setattr(toolopts.tool_opts, "activity", "conversion")

path = utils.download_pkg("kernel")
Expand Down Expand Up @@ -567,9 +567,9 @@ def test_get_rpm_path_from_yumdownloader_output(output):
("envvar", "activity", "should_raise", "message"),
(
(None, "conversion", True, "If you would rather disregard this check"),
("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", "conversion", False, "environment variable detected"),
("CONVERT2RHEL_INCOMPLETE_ROLLBACK", "conversion", False, "environment variable detected"),
(None, "analysis", True, "you can choose to disregard this check"),
("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", "analysis", True, "you can choose to disregard this check"),
("CONVERT2RHEL_INCOMPLETE_ROLLBACK", "analysis", True, "you can choose to disregard this check"),
),
)
def test_report_on_a_download_error(envvar, activity, should_raise, message, monkeypatch, caplog):
Expand Down
8 changes: 4 additions & 4 deletions convert2rhel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,20 +804,20 @@ def report_on_a_download_error(output, pkg):
from convert2rhel.systeminfo import system_info

if toolopts.tool_opts.activity == "conversion":
if "CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK" not in os.environ:
if "CONVERT2RHEL_INCOMPLETE_ROLLBACK" not in os.environ:
loggerinst.critical(
"Couldn't download the %s package. This means we will not be able to do a"
" complete rollback and may put the system in a broken state.\n"
"Check to make sure that the %s repositories are enabled"
" and the package is updated to its latest version.\n"
"If you would rather disregard this check set the environment variable"
" 'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK=1'." % (pkg, system_info.name)
" 'CONVERT2RHEL_INCOMPLETE_ROLLBACK=1'." % (pkg, system_info.name)
)
else:
loggerinst.warning(
"Couldn't download the %s package. This means we will not be able to do a"
" complete rollback and may put the system in a broken state.\n"
"'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK' environment variable detected, continuing"
"'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing"
" conversion." % pkg
)
else:
Expand All @@ -826,7 +826,7 @@ def report_on_a_download_error(output, pkg):
" Check to make sure that the %s repositories are enabled and the package is"
" updated to its latest version.\n"
"Note that you can choose to disregard this check when running a conversion by"
" setting the environment variable 'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK=1'"
" setting the environment variable 'CONVERT2RHEL_INCOMPLETE_ROLLBACK=1'"
" but not during a pre-conversion analysis." % (pkg, system_info.name)
)

Expand Down
4 changes: 2 additions & 2 deletions man/convert2rhel.8
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ before and after the conversion with the output stored in log files rpm_va.log
and rpm_va_after_conversion.log. 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_UNSUPPORTED_INCOMPLETE_ROLLBACK needs to be set to 1 to use this
CONVERT2RHEL_INCOMPLETE_ROLLBACK needs to be set to 1 to use this
argument.

.TP
Expand Down Expand Up @@ -199,7 +199,7 @@ before and after the conversion with the output stored in log files rpm_va.log
and rpm_va_after_conversion.log. 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_UNSUPPORTED_INCOMPLETE_ROLLBACK needs to be set to 1 to use this
CONVERT2RHEL_INCOMPLETE_ROLLBACK needs to be set to 1 to use this
argument.

.TP
Expand Down
4 changes: 2 additions & 2 deletions plans/tier1.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ description+: |
environment+:
CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK: 1
# Since we are removing all the repositories other than rhel-7-server-rpms
# we need pass CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK due to the inability
# we need pass CONVERT2RHEL_INCOMPLETE_ROLLBACK due to the inability
# to download and backup packages
CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK: 1
CONVERT2RHEL_INCOMPLETE_ROLLBACK: 1
# Unavailable kmods may be present on the system due to the kernel package
# not being updated. Mitigate the issues by exporting CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS.
CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ def test_data_collection_acknowledgement(shell, convert2rhel):

@pytest.fixture
def analyze_incomplete_rollback_envar():
os.environ["CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK"] = "1"
os.environ["CONVERT2RHEL_INCOMPLETE_ROLLBACK"] = "1"

yield

del os.environ["CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK"]
del os.environ["CONVERT2RHEL_INCOMPLETE_ROLLBACK"]


@pytest.mark.test_analyze_incomplete_rollback
Expand All @@ -325,7 +325,7 @@ def test_analyze_incomplete_rollback(repositories, convert2rhel, analyze_incompl
# Verify the user is informed to not use the envar during the analysis
assert (
c2r.expect(
"setting the environment variable 'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK=1' but not during a pre-conversion analysis",
"setting the environment variable 'CONVERT2RHEL_INCOMPLETE_ROLLBACK=1' but not during a pre-conversion analysis",
timeout=300,
)
== 0
Expand All @@ -338,7 +338,7 @@ def test_analyze_incomplete_rollback(repositories, convert2rhel, analyze_incompl
c2r.sendline("y")
assert (
c2r.expect(
"'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.",
"'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.",
timeout=300,
)
== 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tag+:
Verify that the /etc/os-release file is restored after the rollback.
/backup_os_release_no_envar:
summary+: |
Restore os-release without CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK
Restore os-release without CONVERT2RHEL_INCOMPLETE_ROLLBACK
description+: |
This case runs the conversion with no repositories available.
Verify that this condition disables the package backup,
Expand All @@ -33,10 +33,10 @@ tag+:

/backup_os_release_with_envar:
summary+: |
Restore os-release with CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK
Restore os-release with CONVERT2RHEL_INCOMPLETE_ROLLBACK
description+: |
This case runs the conversion with no repositories available
and "CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK" envar set.
and "CONVERT2RHEL_INCOMPLETE_ROLLBACK" envar set.
Verify that this condition disables the package backup,
convert2rhel warns the user, but continues the conversion.
tag+:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_backup_os_release_no_envar(
"""
This test case removes all the repos on the system which prevents the backup of some files.
Satellite is being used in all of test cases.
In this scenario there is no variable `CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK` set.
In this scenario there is no variable `CONVERT2RHEL_INCOMPLETE_ROLLBACK` set.
This means the conversion is inhibited in early stage.
"""

Expand All @@ -139,27 +139,27 @@ def test_backup_os_release_no_envar(
),
unregister=True,
) as c2r:
c2r.expect("set the environment variable 'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK")
c2r.expect("set the environment variable 'CONVERT2RHEL_INCOMPLETE_ROLLBACK")
assert c2r.exitstatus != 0

assert shell("find /etc/os-release").returncode == 0


@pytest.fixture(scope="function")
def unsupported_rollback_envar(shell):
os.environ["CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK"] = "1"
os.environ["CONVERT2RHEL_INCOMPLETE_ROLLBACK"] = "1"

yield

del os.environ["CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK"]
del os.environ["CONVERT2RHEL_INCOMPLETE_ROLLBACK"]


@pytest.mark.test_backup_os_release_with_envar
def test_backup_os_release_with_envar(
shell, convert2rhel, custom_subman, katello_package, repositories, unsupported_rollback_envar, kernel_check_envar
):
"""
In this scenario the variable `CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK` is set.
In this scenario the variable `CONVERT2RHEL_INCOMPLETE_ROLLBACK` is set.
This test case removes all the repos on the system and validates that
the /etc/os-release package is being backed up and restored during rollback.
Ref ticket: OAMG-5457. Note that after the test, the $releasever
Expand All @@ -175,9 +175,7 @@ def test_backup_os_release_with_envar(
),
unregister=True,
) as c2r:
c2r.expect(
"'CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion."
)
c2r.expect("'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.")
c2r.sendcontrol("c")

assert c2r.exitstatus != 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_one_kernel_scenario(shell, convert2rhel, one_kernel):
# from Testing Farm
shell("rm /etc/yum.repos.d/copr_build-convert2rhel-1.repo")

os.environ["CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK"] = "1"
os.environ["CONVERT2RHEL_INCOMPLETE_ROLLBACK"] = "1"
os.environ["CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK"] = "1"
# Unavailable kmods may be present on the system due to the kernel package
# not being updated. Mitigate the issues by exporting CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS.
Expand Down

0 comments on commit 061bc66

Please sign in to comment.