-
Notifications
You must be signed in to change notification settings - Fork 87
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
[RHELC-855, RHELC-1153] Recover file changes during a rollback #875
Conversation
Just some high-level review is enough. I'll improve the WIP unit test later. Just if you could check if the structure of the functionality makes sense. |
be7deab
to
7a31bd6
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #875 +/- ##
==========================================
- Coverage 94.21% 94.17% -0.05%
==========================================
Files 47 47
Lines 4377 4516 +139
Branches 775 804 +29
==========================================
+ Hits 4124 4253 +129
- Misses 177 187 +10
Partials 76 76
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Return them as a list of dict, for example: | ||
[{"status":"S5T", "file_type":"c", "path":"/etc/yum.repos.d/CentOS-Linux-AppStream.repo"}] | ||
""" | ||
cmd = ["rpm", "-Va"] |
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.
rpm -Va
is very expensive time-wise. We already run rpm_va in systeminfo. I we should do two things:
- Use the information from systeminfo so that we don't have to run
rpm -Va
a second time here.- Perhaps the parsing of rpm -Va output belongs there as well? I am not sure.
- We have a command line switch
--no-rpm-va
which disables the rpm -Va in system_info. I believe it exists because rpm -Va is so slow that we give the user the option to disable it. we need to do one of three things:- We could deprecate that option and always run rpm -Va.
- We could change the help documentation to note that --no-rpm-va only disables the rpm -Va which is run after the conversion.
- We could make this Action depend on --no-rpm-va not being set.
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.
My opinion about deprecating --no-rpm-va
:
I think this will greatly impact in the wait time for the conversion in some use cases where the user has lots and lots of files, modifications to the system etc... Maybe the last suggestion would be more ideal, i.e: "We could make this Action depend on --no-rpm-va not being set.".
+1 to parse the initial output of rpm -Va
instead of running it a second time. I don't think the parsing needs to be there, it could be in this action as long as it checks if there is anything to parse first. Seems to me that the only case where we care about parsing the contents of that output is here (correct me if I'm wrong).
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.
@abadger, great points. Indeed we should not run the rpm -Va
twice as it is super slow. We shall reuse the output of the first invocation.
I'd vote for keeping the --no-rpm-va switch functionality, i.e. it would prevent running rpm -Va, but because that can lead to an incomplete rollback I'd newly require the user to set the CONVERT2RHEL_INCOMPLETE_ROLLBACK=1
env var (after #683 is merged). What do you think, @r0x0d, @abadger?
The second best option for me would be to "change the help documentation to note that --no-rpm-va only disables the rpm -Va which is run after the conversion".
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.
+1 to that, @bocekm
0c458fd
to
eb0b997
Compare
convert2rhel/unit_tests/actions/pre_ponr_changes/backup_system_test.py
Fixed
Show resolved
Hide resolved
What was changed:
I have a question about printing the messages there. Now it works like this:
It corresponds from my point of view with the other rollback tasks and restoring, where restoring every file is a task. E.g.
But there are many lines about that. Is it okay, or should it be changed to something else? I'm not sure about printing just initial TASK and then just list of the files since we are using stack in backupcontroller, and I'm not sure if solution of this problem wouldn't be too complicated. EDIT: |
eb0b997
to
16187cc
Compare
Applied the suggestions @r0x0d |
@hosekadam I assume you mean one task with many lines for what is rolled back? I think it might be a bit out of scope for the time being if we already have the one solution done. But the UX would be an improvement, so we can create a separate task for that IMO. Perfecting this isn't necessary as it conveys the same message to the user just in a condensed way |
convert2rhel/unit_tests/actions/pre_ponr_changes/backup_system_test.py
Fixed
Show resolved
Hide resolved
e843959
to
c0d1e94
Compare
c0d1e94
to
ab7a01f
Compare
return {"status": status, "file_type": file_type, "path": path} | ||
|
||
@staticmethod | ||
def rollback_files(): |
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.
Is this tested anywhere?
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.
@SpyTec It's not used anywhere, probably some leftover from previous implementation without the NewRestorableFile
. But then it seems to me that I don't handle the missing files - not removing them. I'll take a look if I'm right
ab7a01f
to
75a8324
Compare
# Unset the variable | ||
try: | ||
os.environ.pop("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK") | ||
except KeyError: |
Check notice
Code scanning / CodeQL
Empty except Note
# Unset the variable | ||
try: | ||
os.environ.pop("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK") | ||
except KeyError: |
Check notice
Code scanning / CodeQL
Empty except Note
# If missing conversion is in unknown state | ||
loggerinst.critical("Missing file {rpm_va_output} in it's location".format(rpm_va_output=path)) | ||
|
||
output = output.strip() |
Check failure
Code scanning / CodeQL
Potentially uninitialized local variable Error
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.
Can be fixed in a different PR
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.
Filed an issue for that, dismissing for now.
75a8324
to
a6773d4
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.
Overall LGTM!
try: | ||
os.environ.pop("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK") | ||
except KeyError: | ||
pass |
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.
try: | |
os.environ.pop("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK") | |
except KeyError: | |
pass | |
os.environ.pop("CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK", None) |
Reason:
>>> text = {'a':'text'}
>>> text.pop('b')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'b'
>>> text.pop('b', None)
>>>
# If missing conversion is in unknown state | ||
loggerinst.critical("Missing file {rpm_va_output} in it's location".format(rpm_va_output=path)) | ||
|
||
output = output.strip() |
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.
Can be fixed in a different PR
a6773d4
to
7032695
Compare
7032695
to
18e5aea
Compare
* add integration tests verifying file backup functionality Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
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.
Tests run from #1007
Looks good from my POV
* add integration tests verifying file backup functionality Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
- The --no-rpm-va option has no effect with `convert2rhel analysis` anymore (rpm -Va runs always and a warning is printed when the option is used saying that it has no effect) -- Related: oamg/convert2rhel#875 - The CONVERT2RHEL_DISABLE_TELEMETRY env var was removed -- Related: oamg/convert2rhel#1102 - The CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK was removed in favor of CONVERT2RHEL_INCOMPLETE_ROLLBACK -- Related: oamg/convert2rhel#1147 - The CONVERT2RHEL_LATEST_VERSION env var has never been a valid env var recognized by convert2rhel. It is an ID of one of convert2rhel Actions. A similar env var to this is CONVERT2RHEL_UNSUPPORTED_VERSION which is in recent versions (2.x) removed in favor of CONVERT2RHEL_ALLOW_OLDER_VERSION.
- The --no-rpm-va option has no effect with `convert2rhel analysis` anymore (rpm -Va runs always and a warning is printed when the option is used saying that it has no effect) -- Related: oamg/convert2rhel#875 - The CONVERT2RHEL_DISABLE_TELEMETRY env var was removed -- Related: oamg/convert2rhel#1102 - The CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK was removed in favor of CONVERT2RHEL_INCOMPLETE_ROLLBACK -- Related: oamg/convert2rhel#1147 - The CONVERT2RHEL_LATEST_VERSION env var has never been a valid env var recognized by convert2rhel. It is an ID of one of convert2rhel Actions. A similar env var to this is CONVERT2RHEL_UNSUPPORTED_VERSION which is in recent versions (2.x) removed in favor of CONVERT2RHEL_ALLOW_OLDER_VERSION.
- The --no-rpm-va option has no effect with `convert2rhel analysis` anymore (rpm -Va runs always and a warning is printed when the option is used saying that it has no effect) -- Related: oamg/convert2rhel#875 - The CONVERT2RHEL_DISABLE_TELEMETRY env var was removed -- Related: oamg/convert2rhel#1102 - The CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK was removed in favor of CONVERT2RHEL_INCOMPLETE_ROLLBACK -- Related: oamg/convert2rhel#1147 - The CONVERT2RHEL_LATEST_VERSION env var has never been a valid env var recognized by convert2rhel. It is an ID of one of convert2rhel Actions. A similar env var to this is CONVERT2RHEL_UNSUPPORTED_VERSION which is in recent versions (2.x) removed in favor of CONVERT2RHEL_ALLOW_OLDER_VERSION.
- The --no-rpm-va option has no effect with `convert2rhel analysis` anymore (rpm -Va runs always and a warning is printed when the option is used saying that it has no effect) -- Related: oamg/convert2rhel#875 - The CONVERT2RHEL_DISABLE_TELEMETRY env var was removed -- Related: oamg/convert2rhel#1102 - The CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK was removed in favor of CONVERT2RHEL_INCOMPLETE_ROLLBACK -- Related: oamg/convert2rhel#1147 - The CONVERT2RHEL_LATEST_VERSION env var has never been a valid env var recognized by convert2rhel. It is an ID of one of convert2rhel Actions. A similar env var to this is CONVERT2RHEL_UNSUPPORTED_VERSION which is in recent versions (2.x) removed in favor of CONVERT2RHEL_ALLOW_OLDER_VERSION.
- The --no-rpm-va option has no effect with `convert2rhel analysis` anymore (rpm -Va runs always and a warning is printed when the option is used saying that it has no effect) -- Related: oamg/convert2rhel#875 - The CONVERT2RHEL_DISABLE_TELEMETRY env var was removed -- Related: oamg/convert2rhel#1102 - The CONVERT2RHEL_UNSUPPORTED_INCOMPLETE_ROLLBACK was removed in favor of CONVERT2RHEL_INCOMPLETE_ROLLBACK -- Related: oamg/convert2rhel#1147 - The CONVERT2RHEL_LATEST_VERSION env var has never been a valid env var recognized by convert2rhel. It is an ID of one of convert2rhel Actions. A similar env var to this is CONVERT2RHEL_UNSUPPORTED_VERSION which is in recent versions (2.x) removed in favor of CONVERT2RHEL_ALLOW_OLDER_VERSION. Also, the convert_reboot_requested should not be needed when it comes to just analyzing the system (convert2rhel analyze). The --restart convert2rhel option is heeded just when it comes to the actual conversion. And, when the workshop executes and older convert2rhel version (on purpose) then the pre-conversion analysis ends up with two inhibitors: - Outdated convert2rhel version detected - Outdated packages detected This commit adds the related environment variables to override the inhibitors.
This PR solves problem with not backing up changed package files. When the MD5 checksum of file related to package (got by
rpm -Va
) differs then is backed up and restored during rollback. If the file is missing, during rollback is deleted.Jira Issues: RHELC-855, RHELC-1153
Checklist
[RHELC-]
is part of the PR titleRelease Pending
if relevant