-
Notifications
You must be signed in to change notification settings - Fork 84
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-1672, RHELC-1707, RHELC-1708] Detect a newer version of RHEL kernel in the main transaction #1323
Conversation
@danmyway, the |
@danmyway Do you want to implement the refactor Michal mentioned, or should I take care of it? It seems it will be a bit more work :D |
@hosekadam we can discuss the approach, and I'll see if I'll keep it as a "side quest" for myself 😄 |
ea82aef
to
3ef0a9d
Compare
6f54983
to
7b3d7f9
Compare
# Example output from yum and dnf: | ||
# "Package kernel-4.18.0-193.el8.x86_64 is already installed." | ||
already_installed = re.search(r" (.*?)(?: is)? already installed", output, re.MULTILINE) | ||
if already_installed: |
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.
Dropping this condition, since it will always match something.
I can't imagine a case, where yum install kernel
won't return, that some kernel version is already installed at that point.
convert2rhel/pkghandler.py
Outdated
:rtype: str | ||
|
||
:raises ValueError: If the list is empty, raise a ValueError. | ||
""" | ||
try: | ||
return max(pkgs[1]) | ||
except ValueError: | ||
loggerinst.debug("The list of %s packages is empty." % pkgs[0]) | ||
|
||
return |
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.
:rtype: str | |
:raises ValueError: If the list is empty, raise a ValueError. | |
""" | |
try: | |
return max(pkgs[1]) | |
except ValueError: | |
loggerinst.debug("The list of %s packages is empty." % pkgs[0]) | |
return | |
:rtype: str|None | |
:raises ValueError: If the list is empty, raise a ValueError. | |
""" | |
try: | |
return max(pkgs[1]) | |
except ValueError: | |
loggerinst.debug("The list of %s packages is empty." % pkgs[0]) | |
return None |
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 would vote to continue without the return statement. It does not add anything to the current implementation.
Also, not needed to explicitly say that it returns None
. An empty return will always be None
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.
Going by this, and it makes sense IMO. When returns have some explicit return then we should be explicit everywhere
https://github.com/oamg/convert2rhel/security/code-scanning/926
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 think I'll go with the exception.
Given the context where it's used, if the list is indeed empty, there is something very wrong, and it should raise the exception.
If we ever decide to use the function elsewhere, it can be refactored
info_message = "Conflict of kernels: The running kernel has the same version as the latest RHEL kernel." | ||
loggerinst.info("\n%s" % info_message) | ||
self.add_message( | ||
level="INFO", | ||
id="CONFLICT_OF_KERNELS", | ||
title="Conflict of installed kernel versions", | ||
description=info_message, | ||
) |
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.
Could you also reword this to be easier to understand what this means, why it matters, and how to try to fix it. Atm the comment above gives more detail than the message
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'll try.
7b3d7f9
to
94ea967
Compare
info_message = ( | ||
"Conflict of kernels: The running kernel has the same version as the latest RHEL kernel. " | ||
"The kernel package could not be replaced during the main transaction. " | ||
"We will try to install a lower version of the package, " | ||
"remove the conflicting kernel and then update to the latest security patched version." | ||
) | ||
loggerinst.info("\n%s" % info_message) | ||
self.add_message( | ||
level="INFO", | ||
id="CONFLICT_OF_KERNELS", | ||
title="Conflict of installed kernel versions", | ||
description=info_message, | ||
) |
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.
Given that the info_message talks about doing something but the action message won't be displayed until it's done means it's a bit confusing. We could reword it a bit as a refactor (not a blocker on this PR as it's out of scope, only change if you feel like it)
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.
Agreed, it's kind of mind-bending to figure out the wording 🤯
94ea967
to
8703f9f
Compare
Unit test failing with this, which seems like something that shouldn't happen. Is there something with the implementation?
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1323 +/- ##
==========================================
- Coverage 96.51% 96.43% -0.09%
==========================================
Files 66 66
Lines 4970 4996 +26
Branches 871 876 +5
==========================================
+ Hits 4797 4818 +21
- Misses 97 101 +4
- Partials 76 77 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/packit test --labels sanity |
tests/integration/common/checks-after-conversion/test_yum_check_update.py
Outdated
Show resolved
Hide resolved
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.
qe ack
Sanity suit passed:
|
* detect if the installed RHEL kernel either replaces all original kernel packages or if a newer version is installed Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
* the function was not complete and the evaluation was wrong (e.g. "9" > "10") Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
After Daniel's fix of the InstallRhelKernel, the new unit test are needed to cover those changes.
* drop the distutils and packaging libraries, use the compare_package_version function instead * address review comments Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
* fix the formatting of info message for conflicting kernel version * add debug loggerinst for highest found kernel version * add integration test verifying the latest kernel is installed after the conversion * revert if not non_rhel_kernels back to elif not non_rhel_kernels Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
Due regression RHELC-1707 was found, we needed to change place where kernel update is called. Without this change the system could end up with outdated kernel installed.
* use wildcard asterisk to check all kernel related packages * document which packages are verified 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.
Code looks good.
We are okay with having the global
keyword for now, but we will open a ticket to refactor this in the future. No need to block the PR because of it.
a6c14f0
to
2366043
Compare
In this PR we try to detect, if a RHEL kernel was installed during the main transaction.
We compare which of the installed kernel packages has a higher version.
Jira Issues:
Checklist
[RHELC-]
or[HMS-]
is part of the PR titleRelease Pending
if relevant