Skip to content

Fix pkg.installed ignoring allow_updates for sources installs#69686

Open
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-35385-pkg-allow-updates-sources
Open

Fix pkg.installed ignoring allow_updates for sources installs#69686
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-35385-pkg-allow-updates-sources

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

salt/states/pkg.py:814 computed allow_updates as bool(not sources and kwargs.get("allow_updates")), silently dropping the flag for any package installed via sources:, so _fulfills_version_string kept the exact-match "==" condition against the source package's version and self-updating agents got reinstalled/downgraded on every highstate. The fix removes the "not sources" guard so allow_updates converts the single "==" to ">=", leaving newer installed versions alone, and updates the installed() docstring to say allow_updates also covers sources installs. Verified the new unit test fails on the unpatched line and passes with the fix, both via the shadowed interpreter.

What issues does this PR fix or reference?

Fixes #35385

Previous Behavior

See #35385.

New Behavior

Fix pkg.installed ignoring allow_updates for sources installs. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).

Merge requirements satisfied?

  • Tests written/updated
  • Changelog

Commits signed with GPG?

No

_find_install_targets discarded the allow_updates flag whenever a package
came from sources: (allow_updates = bool(not sources and ...)), forcing an
exact-version match against the version reported by the source package. A
self-updating agent installed via sources would therefore be reinstalled or
downgraded on every highstate. Drop the 'not sources' guard so allow_updates
is honoured for sources installs, and document that behaviour.

Fixes saltstack#35385
…ow_updates

The direct test already existed in this branch and calls
_find_install_targets with sources and allow_updates=True, the exact kwarg
pkg.installed forwards (kwargs["allow_updates"] = allow_updates). This adds
the two inverse guards: with allow_updates left at its default of False a
newer installed version must still be targeted for downgrade to the source
package's version, and with allow_updates=True an older installed version
must still be targeted for upgrade, so the fix cannot silently widen into
ignoring version mismatches for sources installs.

Claude-Session: https://claude.ai/code/session_01MF2AuQNhBZg4HDt1x6xxCu
@dwoz dwoz added the test:full Run the full test suite label Jul 7, 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.

2 participants