Fix pkg.list_holds returning empty on dnf5 (parse versionlock.toml with tomllib) (#69607) - #69608
Merged
Merged
Conversation
_list_holds_dnf5 parsed /etc/dnf/versionlock.toml via salt.serializers.tomlmod, which depends on the third-party 'toml' library. 'toml' is a CI-only dependency and is not bundled in the onedir packages, and the onedir ships Python 3.10 (no stdlib tomllib), so the parse failed silently and pkg.list_holds always returned []. With hold: True this made pkg.installed re-hold packages on every run. Parse with the standard-library tomllib (available once the onedir ships Python 3.11 in 3006.27, see saltstack#69526), falling back to the toml serializer on older interpreters where it is installed. Fixes saltstack#69607
Expand test coverage of salt/modules/yumpkg.py beyond the saltstack#69607 change, per the contributor policy of improving coverage in modules a PR touches: - version_cmp: assert it delegates to lowpkg.version_cmp with ignore_epoch - group_diff: assert group members are split into installed/not-installed - list_repos: assert .repo files are parsed, non-repo files skipped, and each repo records its source file
dwoz
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
On dnf5 systems (Fedora 41+, AlmaLinux 10),
pkg.list_holdsalways returned an empty list even when packages were held._list_holds_dnf5parsed/etc/dnf/versionlock.tomlviasalt.serializers.tomlmod, which depends on the third-partytomllibrary.tomlis a CI-only dependency and is not bundled in the onedir packages, and the onedir ships Python 3.10 (no stdlibtomllib), so the parse failed silently andlist_holdsreturned[]. Withhold: True,pkg.installedthen re-held packages on every run. (pkg.hold/pkg.unholdwork fine -- they shell out -- only reading holds was broken.)This parses the file with the standard-library
tomllibinstead, falling back to thetomlserializer on older interpreters where it is installed.What issues does this PR fix or reference?
Fixes #69607. Remaining gap from the partial dnf5 versionlock fix in 3006.26 (#69181).
Depends on #69526:
tomllibis standard library only on Python 3.11+, which the onedir gains in 3006.27. On the 3006.26 onedir (Python 3.10) neithertomllibnortomlis present, so the fix takes full effect once the Python 3.11 bump lands; thetomlfallback covers any non-onedir 3.10 environment that has the library installed.Previous Behavior
salt-call pkg.list_holdson dnf5 loggedFailed to parse dnf5 versionlock file ...: name 'toml' is not definedand returned[], even with packages held.New Behavior
pkg.list_holdsreads the holds from/etc/dnf/versionlock.tomlusingtomllib, returning e.g.tree-0:2.2.1-4.fc44.*.Platform test matrix
pkg.hold treewrites/etc/dnf/versionlock.toml, butpkg.list_holdslogsname 'toml' is not definedand returns[]. The same mechanism applies to every dnf5 platform (Fedora 41+, AlmaLinux 10).tomllibpath (run under Python 3.11+), including a regression test (test_list_holds_dnf5_parses_without_toml_library) that fails against the previoustomlmod-based implementation. The released 3.10 onedir cannot exercisetomllib, so the fix lands in shipped packages with the Python 3.11 bump (3006.27, [TECH DEBT] Ship python 3.11 in 3006.27 #69526).A second commit adds unit tests for previously-untested
yumpkgfunctions (version_cmp,group_diff,list_repos) to raise coverage of the touched module.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
No