Skip to content

Fix pkg.list_holds returning empty on dnf5 (parse versionlock.toml with tomllib) (#69607) - #69608

Merged
dwoz merged 4 commits into
saltstack:3006.xfrom
ggiesen:fix-dnf5-list-holds-tomllib
Jul 4, 2026
Merged

Fix pkg.list_holds returning empty on dnf5 (parse versionlock.toml with tomllib) (#69607)#69608
dwoz merged 4 commits into
saltstack:3006.xfrom
ggiesen:fix-dnf5-list-holds-tomllib

Conversation

@ggiesen

@ggiesen ggiesen commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

On dnf5 systems (Fedora 41+, AlmaLinux 10), pkg.list_holds always returned an empty list even when packages were held. _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 list_holds returned []. With hold: True, pkg.installed then re-held packages on every run. (pkg.hold/pkg.unhold work fine -- they shell out -- only reading holds was broken.)

This parses the file with the standard-library tomllib instead, falling back to the toml serializer 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: tomllib is standard library only on Python 3.11+, which the onedir gains in 3006.27. On the 3006.26 onedir (Python 3.10) neither tomllib nor toml is present, so the fix takes full effect once the Python 3.11 bump lands; the toml fallback covers any non-onedir 3.10 environment that has the library installed.

Previous Behavior

salt-call pkg.list_holds on dnf5 logged Failed to parse dnf5 versionlock file ...: name 'toml' is not defined and returned [], even with packages held.

New Behavior

pkg.list_holds reads the holds from /etc/dnf/versionlock.toml using tomllib, returning e.g. tree-0:2.2.1-4.fc44.*.

Platform test matrix

  • Bug reproduced on Fedora 44 (dnf5) with the official onedir salt 3006.26 (Python 3.10): pkg.hold tree writes /etc/dnf/versionlock.toml, but pkg.list_holds logs name 'toml' is not defined and returns []. The same mechanism applies to every dnf5 platform (Fedora 41+, AlmaLinux 10).
  • Fix validated by unit tests exercising the tomllib path (run under Python 3.11+), including a regression test (test_list_holds_dnf5_parses_without_toml_library) that fails against the previous tomlmod-based implementation. The released 3.10 onedir cannot exercise tomllib, 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 yumpkg functions (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.

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

No

ggiesen added 2 commits June 30, 2026 14:11
_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
@ggiesen
ggiesen requested a review from a team as a code owner June 30, 2026 18:12
@dwoz dwoz added this to the Sulphur v3006.27 milestone Jun 30, 2026
@dwoz dwoz added the test:full Run the full test suite label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants