Fix pkg.installed ignoring allow_updates for sources installs#69686
Open
ggiesen wants to merge 2 commits into
Open
Fix pkg.installed ignoring allow_updates for sources installs#69686ggiesen wants to merge 2 commits into
ggiesen wants to merge 2 commits into
Conversation
_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
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?
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?
Commits signed with GPG?
No