Skip to content
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-1130] Fix failing yum transaction validation #1035

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

hosekadam
Copy link
Member

@hosekadam hosekadam commented Jan 17, 2024

The problem is related to how we remove the excluded packages. When “rpm -e –nodeps” is used, yum doesn’t know that the package was removed. On the removed package can be depending some other package (pkg1 depends on removed pkg). So then during processing the yum operations (_perform_operations), specifically update operation (reinstall is fine), the dependency (which was satisfied before conversion and then removed by us manually using rpm -e –nodeps) is not checked and results in missing dependency.

This problem with not checking the dependency is solved in later versions, but in the one present in our converted systems. So we need to swap the packages mainly on CentOS 7 (and similar) systems.

The solution uses “yum swap” command, which is based on reinstall and install the package using yum api. The “yum swap” is mostly reimplemented on our side, using the api calls (_swap_problematic_packages).

We can use the swap command when we are removing a package from the original system vendor (like centos-logos) and this package has its replacement from rhel (in this case redhat-logos). This requires the mapping in the configuration file.

Jira Issues: RHELC-1130

Checklist

  • PR has been tested manually in a VM (either author or reviewer)
  • Jira issue has been made public if possible
  • [RHELC-] is part of the PR title
  • GitHub label has been added to help with Release notes
  • PR title explains the change from the user's point of view
  • Code and tests are documented properly
  • The commits are squashed to as few commits as possible (without losing data)
  • When merged: Jira issue has been updated to Release Pending if relevant

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (790db4b) 94.89% compared to head (a295f98) 94.97%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1035      +/-   ##
==========================================
+ Coverage   94.89%   94.97%   +0.08%     
==========================================
  Files          50       50              
  Lines        4565     4601      +36     
  Branches      812      819       +7     
==========================================
+ Hits         4332     4370      +38     
+ Misses        156      155       -1     
+ Partials       77       76       -1     
Flag Coverage Δ
centos-linux-7 90.04% <77.77%> (-0.06%) ⬇️
centos-linux-8 91.03% <77.77%> (-0.07%) ⬇️
centos-linux-9 91.08% <77.77%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -186,19 +225,24 @@ def _perform_operations(self):
# package. This is an inconsistency that could lead to packages
# being outdated in the system after the conversion.
if can_update:
loggerinst.info("Package %s will be updated.", pkg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder that we can get rid of this later.

We don't need the info log for update/reinstall/downgrade.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it from this PR. But I'm wondering if this cannot be used for better debugging of the yum transaction. If yes, then it could be part of https://issues.redhat.com/browse/RHELC-999 What do you think? @r0x0d

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I guess this is not related. The log message we used here to debug is mainly for us to identify which package is being added to the transaction and the operation related to the package.

What the ticket https://issues.redhat.com/browse/RHELC-999 asks for is to capture error messages and have a better handling for that. We could potentially solve it by improving our callback classes and try to capture and output better messages there.

Also, the errors about dependency solving only happen when we reach the part where try to resolve the dependencies.


Said that, there might be one benefit to log those packages as a DEBUG. That would help us to understand the operation tied to the package, potentially saving us some time in the analysis when a report is opened.

But I don't think we need to leave this for now, again, improving our callback classes might make more sense than placing those logs here.

convert2rhel/systeminfo.py Outdated Show resolved Hide resolved
@r0x0d r0x0d added kind/bug-fix A bug has been fixed tests/tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`. labels Jan 17, 2024
@has-bot
Copy link
Member

has-bot commented Jan 17, 2024

/packit test --labels tier0


@oamg/conversions-qe please review results and provide ack.

convert2rhel/systeminfo.py Fixed Show fixed Hide fixed
convert2rhel/systeminfo.py Fixed Show fixed Hide fixed
@hosekadam
Copy link
Member Author

Finished the part with YUM swap (tests, comments). I have a few questions:

  • Do you agree with | symbol in config file for mapping the packages?
  • Do we want to implement the swap for other system than CentOS 7 (and similar, like Oracle 7)?
    The bug was occurring only on system with YUM package manager, on DNF wasn't any problem. My suggestion is to add to the config file note, that the swap_pkgs variable is used only on systems with YUM. And don't implement the swap for dnf.

What do you think? @r0x0d @bookwar @bocekm ? I added a short summary to the description of this PR.

I also added mapping for the packages which I found has equivalent of them in rhel repositories. Mostly, I finished up with packages centos-* mapped to redhat-* for now (so added just centos-bookmarks from the previous state). I have one more candidate libreport-centos, but I'm not sure about this one if it couldn't cause a problem. I need to test them more (all of them). So the mapping is still in progress.

except AttributeError:
# Leave the swap packages dict empty, missing swap_pkgs in config file
self.logger.warning("Leaving the swap package list empty. Missing swap_pkgs key in configuration file.")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the extra safety here! Pretty clever!

@r0x0d
Copy link
Member

r0x0d commented Jan 22, 2024

Finished the part with YUM swap (tests, comments). I have a few questions:

* Do you agree with `|` symbol in config file for mapping the packages?

* Do we want to implement the swap for other system than CentOS 7 (and similar, like Oracle 7)?
  The bug was occurring only on system with YUM package manager, on DNF wasn't any problem. My suggestion is to add to the config file note, that the `swap_pkgs` variable is used only on systems with YUM. And don't implement the swap for dnf.

What do you think? @r0x0d @bookwar @bocekm ? I added a short summary to the description of this PR.

I also added mapping for the packages which I found has equivalent of them in rhel repositories. Mostly, I finished up with packages centos-* mapped to redhat-* for now (so added just centos-bookmarks from the previous state). I have one more candidate libreport-centos, but I'm not sure about this one if it couldn't cause a problem. I need to test them more (all of them). So the mapping is still in progress.


Do you agree with | symbol in config file for mapping the packages?

I don't mind having the |.

Do we want to implement the swap for other system than CentOS 7 (and similar, like Oracle 7)?

I do think that we have to propagate the configuration file changes to the other systems to keep it consistent across the variants.

Without that, the user might not know that this option is supported by us. I'm not quite sure if we need to implement the solution to DNF as well, although, it would be nice to have, no one asked for that yet and it seems that, at least in DNF, the tool deals with it more reliably.

But I do see that we have a bunch of packages that could benefit from this swap and be removed from the exclude list. For example, maybe this is a good candidate: https://github.com/hosekadam/convert2rhel/blob/pr/hosekadam/1035/convert2rhel/data/8/x86_64/configs/oracle-8-x86_64.cfg#L12-L13.

Ideally, we want to maintain consistency between the two versions.

@hosekadam hosekadam force-pushed the httpd-issue branch 3 times, most recently from a6f6444 to 63aecfc Compare January 26, 2024 12:09
@hosekadam hosekadam marked this pull request as ready for review January 31, 2024 15:34
@hosekadam
Copy link
Member Author

The all swap pkgs lists for each system were tested on the latest version of it. I've tested by installing the packages to swap prior to the conversion, then run conversion and then checked if the target package is present.

There are the results with links to the logs. The centos7 was tested twice, first attempt for the centos* pkgs and second for the libreport.

So from my point of view, this is finally ready (after removing the comment from the centos7 config file, I will do it in a moment)!

Copy link
Member

@r0x0d r0x0d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. But an extra pair of eyes might be required before approving.

Nice work!

@hosekadam hosekadam requested a review from Venefilyn February 13, 2024 14:29
Copy link
Member

@Venefilyn Venefilyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. Though one thing I'd like changed is the title. Try something that addresses the implementation and then how it fixes the bug in the description. Currently the title reads like a bug report

Implementation looks great!

convert2rhel/pkgmanager/handlers/dnf/__init__.py Outdated Show resolved Hide resolved
convert2rhel/pkgmanager/handlers/dnf/__init__.py Outdated Show resolved Hide resolved
@Venefilyn
Copy link
Member

Needs a rebase

@hosekadam hosekadam force-pushed the httpd-issue branch 2 times, most recently from 643b12d to 664c4ea Compare February 19, 2024 13:38
@hosekadam
Copy link
Member Author

Rebased and applied the review

@hosekadam hosekadam changed the title [RHELC-1130] convert2rhel fails when httpd is installed, not downloading redhat-logos [RHELC-1130] Swap base os specific packages Feb 19, 2024
@hosekadam
Copy link
Member Author

Rebased to have changes from #1095

Copy link
Member

@r0x0d r0x0d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, but in general, it looks pretty good!

@r0x0d
Copy link
Member

r0x0d commented Feb 21, 2024

/packit test --labels tier0

@r0x0d r0x0d merged commit 773af3e into oamg:main Feb 21, 2024
45 of 57 checks passed
@Venefilyn Venefilyn mentioned this pull request Feb 22, 2024
jochapma pushed a commit to jochapma/convert2rhel that referenced this pull request Mar 11, 2024
@bocekm bocekm changed the title [RHELC-1130] Swap base os specific packages [RHELC-1130] Fix failing yum transaction validation Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix A bug has been fixed tests/tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants