[BUG] onchanges
is firing the requiring state when required is also prereq
by a failing third state
#62408
Closed
2 tasks done
Labels
Bug
broken, incorrect, or confusing behavior
Requisite
Issue is in Salt's Requisite system
Sulfur v3006.0
release code name and version
Milestone
Description
The above is stripped-down example code I have in production. The intention is that whenever the foo grain is about to be changed, then State B should be run, and a Slack message should be generated. If every state succeeds properly, then this actually works fine, and the grain gets changed.
The problem that I am seeing is when
State B
happens to fail, the grain is not set (which is aligned with the documentation forprereq
), but the Slack message gets sent anyway. This results in one Slack message per highstate untilState B
passes.In the highstate runs where
State B
fails, the returns log showsgrains: foo
state is clearly only run in test mode. The results include "Is set to be added" and has a changes dictionary, but the grain never gets set.In the highstate runs where
State B
passes, the returns log showsgrains: foo
state returns with changes and "Has been set to. . . " language, and the grain IS set.While it is in-line with the
prereq
docs for a failure inState B
to stop the execution ofgrains:foo
, it is also called out in theonchanges
documentation that the required state (grains: foo
) needs to returnTrue
before the requiring state (slack: Notify Team
) executes. Here the grains call is clearly failing, but the slack call happens anyway.Theory:
prereq
onState B
causesgrains: foo
state to be run in test modeState B
failing means thatgrains: foo
state is never re-run so that it completes (as designed)onchanges
onslack: Notify Team
state finds the "True with changes" results of thegrain: foo
state, is unaware that these are test-mode results prompted by aprereq
requisite in a different state, and allowsslack: Notify Team
state to run as though the grain had been changedSetup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
The following testing
SLS
illustrates the problem:The results of this state run are below:
Expected behavior
If
State B
fails, and soprereq
prevents the actual run of the required state, then theonchanges
requisite should prevent the run of theonchanges
-requiring state since theonchanges
-required state never completed.Actual Behavior
When
State B
fails, the required state is never re-evaluated as failing, and theonchanges
requisite picks up the test-mode results as evidence that theonchanges
requisite is satisfied, firing the final state incorrectly.Screenshots
If applicable, add screenshots to help explain your problem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Master
minion
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: