-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify supported target OS version in actors #1328
Verify supported target OS version in actors #1328
Conversation
Thank you for contributing to the Leapp project!Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergeable.
Packit will automatically schedule regression tests for this PR's build and latest upstream leapp build.
Note that first time contributors cannot run tests automatically - they need to be started by a reviewer. It is possible to schedule specific on-demand tests as well. Currently 2 test sets are supported,
See other labels for particular jobs defined in the Please open ticket in case you experience technical problem with the CI. (RH internal only) Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please contact leapp-infra. |
ca83f6f
to
46d9e31
Compare
I put his actor into Facts phase because when I upgraded for example with
When I added this before actor checkphase, now there are still those errors, but Inhibitor is triggered successfully. |
46d9e31
to
1d04457
Compare
Latest push rebased against main |
1d04457
to
d100c69
Compare
/packit retest-failed |
35da727
to
87c7da0
Compare
Latest pushes fixed test's misspells |
87c7da0
to
4cbe76c
Compare
4cbe76c
to
3e77258
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to explain all wanted changes in the comments, with added suggestions for updated reports. Also, you are right about the misleading errors when incorrect major version is specified. It really bad from my pov as we are aware that this is happening from time to time to people and they could be very confused about that. Let's raise the StopActorExecutionError
in such a case to protect sanity of readers. Add function like this into the ipuworkflowconfig:
def check_target_major_version(curr_version, target_version):
required_major_version = int(curr_version.split('.')[0]) + 1
specified_major_version = int(target_version.split('.')[0])
if specified_major_version != required_major_version:
raise StopActorExecutionError(
message='Specified invalid major version of the target system',
details={
'Specified targed major version': str(specified_major_version),
'Required target major version': str(required_major_version),
'hint': (
'The in-place upgrade is possible only to the next system'
' major version: {ver}. Current solution depends heavily on this'
' value and violation of this rule leads to various errors which'
' could be very confusing.'
.format(ver=required_major_version)
)
}
)
and call it before producing the IPUConfig
:
check_target_major_version(os_release.version_id, target_version)
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
In the
|
Feel free to reword it. The msg is that this value is crucial for the functionality of actors and incorrect value leads to undefined behaviour with number of errors, so we must stop it here. |
|
||
|
||
def _get_env_mocked(key, default=None): | ||
return os.environ.get(key, default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not work with envars in unit tests inside os.environ
monkeypatch.setattr(verifytargetversion, 'get_env', lambda key, default=None: _get_env_mocked(key, default)) | ||
monkeypatch.setattr(verifytargetversion, 'get_target_version', lambda: target_version) | ||
monkeypatch.setenv('LEAPP_UPGRADE_PATH_FLAVOUR', 'default') | ||
monkeypatch.setenv('LEAPP_UPGRADE_PATH_TARGET_RELEASE', target_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to set this envar based on the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar for other mocking in this function. mock the current _actor using the CurrentActorMocked
class from testutils.py
. it's more elegant solution, resolving number of mocks in this function. also, do not use setenv
when the actor is not working with os.environ
directly - which usually should not.
I will send updated version in the commit.
name = 'verify_target_version' | ||
consumes = () | ||
produces = (Report,) | ||
tags = (FactsPhaseTag, IPUWorkflowTag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check actors should be executed during ChecksPhaseTag
if unsupported and not leapp_unsupported: | ||
hint = ( | ||
'Choose a supported version of the target OS for the upgrade.' | ||
' Alternatively, if you require to upgrade using an unsupported upgrade path,' | ||
' set the `LEAPP_UNSUPPORTED=1` environment variable to confirm you' | ||
' want to upgrade on your own risk.' | ||
) | ||
|
||
reporting.create_report([ | ||
reporting.Title('Specified version of the target system is not supported'), | ||
reporting.Summary( | ||
'The in-place upgrade to the specified version ({tgt_ver}) of the target system' | ||
' is not supported from the current system version. Follow the official' | ||
' documentation for up to date information about supported upgrade' | ||
' paths and future plans (see the attached link).' | ||
' The in-place upgrade is enabled to the following versions of the target system:{sep}{ver_list}' | ||
.format( | ||
sep=FMT_LIST_SEPARATOR, | ||
ver_list=FMT_LIST_SEPARATOR.join(supported_target_versions), | ||
tgt_ver=target_version | ||
) | ||
), | ||
reporting.Groups([reporting.Groups.INHIBITOR]), | ||
reporting.Severity(reporting.Severity.HIGH), | ||
reporting.Remediation(hint=hint), | ||
reporting.ExternalLink( | ||
url='https://access.redhat.com/articles/4263361', | ||
title='Supported in-place upgrade paths for Red Hat Enterprise Linux' | ||
) | ||
]) | ||
raise StopActorExecution() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems my long comment about this has been dropped by GH :/ but this can be written in more simple way if initial conditions are negated.
I will push updated commit in ~15min with all changes
@@ -0,0 +1,54 @@ | |||
from leapp import reporting | |||
from leapp.cli.commands import command_utils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actors should not import anything from command utils. The thing is that the content inside the leapp repository becomes dependent on stuff for the CLI which is outside of the repository. Also the function is interacting with the system storage to load the data file which is something we do not want actually in the ChecksPhase
.
repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
repos/system_upgrade/common/actors/verifytargetversion/libraries/verifytargetversion.py
Outdated
Show resolved
Hide resolved
from leapp.tags import FactsPhaseTag, IPUWorkflowTag | ||
|
||
|
||
class VerifyTargetVersion(Actor): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rather use CheckTargetVersion
instead of Verify
to correspond with usual naming used for actors in these repositories.
706fbea
to
fed32f3
Compare
b0506dc
to
825e093
Compare
This is hackish precursor to move checking of the specified target system versions into actors to be able to create report when unsupported target version is specified. The problem is that currently there is no information about the supported upgrade paths in messages. Also, the information about supported source and target versions are stored in two different places (in system upgrade common repo): * shared configs.version library * files/upgrade_paths.json As a temporary solution let's introduce IPUPaths message which will contain filtered data from the json file based on: * the upgrade flavour (default, saphana) * and source major version There is no value to print information to users about different upgrade paths for other flavours and OS major versions. The model is marked as deprecated so we can remove it in the next release when we redesign this solution to unify how actors get this data (and define them just in one place). jira: RHEL-51072
825e093
to
797e0d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a single minor comment that needs to be addressed (now, or in a separate PR). Once I test this, I can will approve, since there are no blockers code-wise
repos/system_upgrade/common/actors/checktargetversion/tests/test_checktargetversion.py
Outdated
Show resolved
Hide resolved
Originally when user specified the target system release using `--target` CLI option the verification has been performed immediately as only supported releases have been listed as possible choices for this option. The benefit of this solution was that users did not have to wait for all other checks to realize they execute leapp probably incorrectly. Unfortunately, * number of users do not understand why only some versions are supported * users upgrading with via various webUIs presenting only leapp reports could not see the error message available in terminal To resolve this problem the checks are moved into actors so in case of specified unsupported target version the information is present in generated leapp reports. Current behaviour is like this: * in case of invalid input (incorrect format of input data) the hard error is raised as before immediately. Malformed input data will not be processed anyhow by any actors * report error when the specified target major version is not direct successor of the current system version. I.e. specify 10.0 when upgrading from RHEL 8 (only RHEL 9 is acceptable). * this prevents number of cryptic errors as actors are not prepared for this situation * report standard inhibitor if the target release is not in the defined upgrade path, unless LEAPP_UNSUPPORTED=1 * running leapp in unsupported (devel) mode skips the inhibitor and entire report Additional changes: * Update error message when format of target version is incorrect to clarify the expected version format jira: RHEL-51072 Co-authored-by: Petr Stodulk <[email protected]>
797e0d0
to
8d3a73e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but as significant co-author I will wait for second green tick :)
/packit copr-build |
I have tested upgrading from 8.10 to various target versions with the following results:
Using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Originally when user specified the target system release using
--target
CLI option the verification has been performed immediately as only supported releases have been listed as possible choices for this option. The benefit of this solution was that users did not have to wait for all other checks to realize they execute leapp probably incorrectly. Unfortunately,could not see the error message available in terminal
To resolve this problem the checks are moved into actors so in case of specified unsupported target version the information is present in generated leapp reports.
Current behaviour is like this:
Additional changes:
NOTE
Note this solution introduces also
IPUPaths
msg which is by design marked already as deprecated. Read the commit msg for detail information.jira: RHEL-51072