Repository navigation
Keep the test mode result and do not include force_mod_watch in state results (follow-up to #68960) - #70972
Open
mitar wants to merge 2 commits into
Open
Keep the test mode result and do not include force_mod_watch in state results (follow-up to #68960)#70972mitar wants to merge 2 commits into
mitar wants to merge 2 commits into
Conversation
When a watching state returns force_mod_watch and its normal run made changes, the state system runs mod_watch as well and merges both results. The merge converted both results with bool(), so in test mode, where both runs return None to report that they would make changes, the merged result became False and the state was reported as failed. Merge the results so that False wins over None, and None wins over True. Follow-up to saltstack#68960.
force_mod_watch only tells the state system whether to run mod_watch, but call_chunk removed it from the result only when a watched state had changes. In every other case, such as a state without a watch requisite, a watched state without changes, or a result of mod_watch itself, the key remained in the state's result. state.single and state.low call State.call directly, so they kept the key as well. Remove the key at the end of call_chunk on every path, and in state.single and state.low. Follow-up to saltstack#68960.
3 tasks done
3 tasks done
mitar
added a commit
to mitar/saltext-dockermod
that referenced
this pull request
Nov 28, 2026
The functional test read force_mod_watch from the state's result, which works only while Salt leaves the key in results. saltstack/salt#70972 removes it from every result, so the test now checks the change which the flag depends on: connecting a network reports only network changes, and the container keeps its Id and its start time. The unit tests check the flag itself.
2 of 3 tasks
This branch was previously deployed
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?
Fixes two bugs in the
force_mod_watchopt-in which #68960 added. #68960 is only on master, so no release has them yet.force_mod_watch: Trueand its normal run made changes, the state system runsmod_watchas well and merges both results withbool(ret.get("result")) and bool(mod_ret.get("result", True)). In test mode both runs returnNoneto report that they would make changes, so the merged result becameFalseand a dry run reported the state as failed. The merge now keeps all three values:Falseif either run failed, otherwiseNoneif either run would make changes, otherwiseTrue.force_mod_watchin results.call_chunkremoved the key only in the branch where a watched state had changes. In every other case (no watch requisite, a watched state without changes, a result ofmod_watchwhich replaces the normal one) the key remained in the state's result and in the job return.state.singleandstate.lowcallState.calldirectly, so they kept it too. The key is now removed at the end ofcall_chunkon every path, and instate.singleandstate.low.Each fix is a separate commit with its own test.
What issues does this PR fix or reference?
Follow-up to #68960 (issue #68958).
Previous Behavior
With this SLS:
state.applywithtest=Truereportswatcherwithresult: False, although nothing failed.watcherwithout thewatchrequisite, and the result ofstate.single test.succeed_with_changes name=example force_mod_watch=True, containforce_mod_watch: True.New Behavior
state.applywithtest=Truereportswatcherwithresult: None, and the comment ofmod_watch("Watch statement fired.") is still merged in.force_mod_watch.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
doc/ref/states/requisites.rstnow says how the combined result is computed, including test mode.changelog/68958.fixed.md, the entry of Allow watching states to opt-in to mod_watch when normal run had changes #68960, so that the unreleased entry describes the final behavior. The changelog check accepts only one<issue>.<type>.mdfile per issue and type, and these bugs have no issue of their own. I can add a separate entry if you prefer one.tests/pytests/functional/modules/state/requisites/test_watch.py. Each fails without its fix. All requisite core tests (101),tests/pytests/unit/modules/state(71),tests/pytests/unit/state(128) and the othertests/pytests/functional/modules/statetests (139) pass.Commits signed with GPG?
Yes