Skip to content

Redesign dnf shared libraries & scan installed DNF comps#1507

Draft
pirat89 wants to merge 7 commits intooamg:mainfrom
pirat89:modify-dnf-libs
Draft

Redesign dnf shared libraries & scan installed DNF comps#1507
pirat89 wants to merge 7 commits intooamg:mainfrom
pirat89:modify-dnf-libs

Conversation

@pirat89
Copy link
Copy Markdown
Member

@pirat89 pirat89 commented Mar 10, 2026

Consolidate DNF-related libraries (dnfconfig, dnfplugin, module) into a new dnflibs package for better organization. The old module locations remain as deprecated shims using @deprecated decorator, ensuring full backward compatibility while encouraging migration to the new structure.

I plan additional changes in future and I consider the original structure problematic, like:

  • I want to expose some of private functions, but there is no good
    place where to put them - and keeping them in original places is
    not good.
  • The module.py library has kind of ambiguous name and it was not
    clear what to expect from it without reading the content.

With this change, all actions related to DNF are nicely closured.

Changes:

  • Create repos/system_upgrade/common/libraries/dnflibs/ package
  • Move dnfconfig.py to dnflibs/dnfconfig.py
  • Move dnfplugin.py to dnflibs/dnfplugin.py
  • Move module.py to dnflibs/dnfmodule.py (renamed)
  • Mark original libraries and their content as deprecated
  • Update imports in the code to use the new libraries instead
  • Update the documentation to reflect deprecated functionality

This PR is prerequisite for #1506.


TODO

  • find agreement on the naming :)
  • drop dead code & deprecated functionality
  • replace StopActorExecutionError in libs by new exceptions (inherit from StopActorExecutionError)
  • update unit tests
  • implement scanner of DNF comps

@github-actions
Copy link
Copy Markdown

Thank you for contributing to the Leapp project!

Please note that every PR needs to comply with the leapp-repository contribution and development guidelines and must pass all tests in order to be mergeable.
If you want to request a review or rebuild a package in copr, you can use following commands as a comment:

  • review please @oamg/developers to notify leapp developers of the review request
  • /packit copr-build to submit a public copr build using packit

Packit will automatically schedule regression tests for this PR's build and latest upstream leapp build.
However, here are additional useful commands for packit:

  • /packit test to re-run manually the default tests
  • /packit retest-failed to re-run failed tests manually
  • /packit test oamg/leapp#42 to run tests with leapp builds for the leapp PR#42 (default is latest upstream - main - 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, beaker-minimal and kernel-rt, both can be used to be run on all upgrade paths or just a couple of specific ones.
To launch on-demand tests with packit:

  • /packit test --labels kernel-rt to schedule kernel-rt tests set for all upgrade paths
  • /packit test --labels beaker-minimal-8.10to9.4,kernel-rt-8.10to9.4 to schedule kernel-rt and beaker-minimal test sets for 8.10->9.4 upgrade path

See other labels for particular jobs defined in the .packit.yaml file.

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.

Consolidate DNF-related libraries (dnfconfig, dnfplugin, module) into a
new dnflibs package for better organization. The old module locations
remain as deprecated shims using @deprecated decorator, ensuring full
backward compatibility while encouraging migration to the new structure.

I plan additional changes in future and I consider the original
structure problematic, like:
* I want to expose some of private functions, but there is no good
  place where to put them - and keeping them in original places is
  not good.
* The module.py library has kind of ambiguous name and it was not
  clear what to expect from it without reading the content.

With this change, all actions related to DNF are nicely closured.

Changes:
- Create repos/system_upgrade/common/libraries/dnflibs/ package
- Move dnfconfig.py to dnflibs/dnfconfig.py
- Move dnfplugin.py to dnflibs/dnfplugin.py
- Move module.py    to dnflibs/dnfmodule.py (renamed)
- Mark original libraries and their content as deprecated
- Update the documentation to reflect deprecated functionality

Assisted-by: Claude Sonnet 4.5
@pirat89 pirat89 added the docs Related to documentation label Mar 10, 2026
@pirat89 pirat89 added this to the 8.10/9.9 milestone Mar 10, 2026
Update all actors and tests to import DNF libraries from the new
dnflibs package location instead of the deprecated root paths.

Changes:
- Update dnfplugin imports to use dnflibs.dnfplugin
- Update module imports to use dnflibs.dnfmodule
- Affects 8 actors and 3 test files

This completes the migration to the new library structure, ensuring
all internal code uses the new import paths while maintaining backward
compatibility through deprecation shims.

Assisted-by: Claude Sonnet 4.5
@pirat89 pirat89 changed the title Modify dnf libs Redesign dnf shared libraries & scan installed DNF comps Mar 10, 2026
pirat89 added 4 commits March 10, 2026 14:01
This function is not used anywhere anymore. Let's just remove it.
This has been deprecated for a long time - dropping it finally to
clean the code a little bit after the moving to a new path.
Originally the library raised usually StopActorExecutionError exception
in case of issues. But as we agreed recently, we want to start to
raise rather proper exceptions in libraries and handle this better
in callers (actors).

For the comfort (and sake of safety) the newly created exception
classes are inherit from the StopActorExecutionError, so these
exceptions will be properly handled also if they are not caught
correctly in actors. Also, in case of this library we kind of know
that we are the only callers of these functions as they are fundamental
for the upgrade process and majority of them can be executed just once
per the upgrade process.

Docstrings in functions have been properly updated to reflect the
change.

List of new exceptions:
 * DNFPluginInstallError
 * DNFExecutionError
 * DNFUpgradeTransactionError
 * RegisteredWorkaroundApplicationError
@pirat89 pirat89 added enhancement New feature or request deprecation Any change in the set of deprecation functionality. labels Mar 10, 2026
Disclaimer: This is temporary commit supposed to be modified/dropped.
I plan to move and change the _create_or_get_dnf_base function, so
it can be used also in actors or other libraries directly for
additional purposes.

The original StopActorExecutionError exception has been replaced by
DNFRepoError so it's easier to identify and handle the possible
problem in callers (actors).

The new exception class is inherited from StopActorExecutionError
so such an exception is still handled by framework if not caught
by a caller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecation Any change in the set of deprecation functionality. docs Related to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant