pre-required state always runs twice regardless whether changes empty or not
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
According to the documentation
If the "changes" key contains a populated dictionary, it means that the pre-required state expects changes to occur when the state is actually executed, as opposed to the test-run. The pre-requiring state will now actually run. If the pre-requiring state executes successfully, the pre-required state will then execute. If the pre-requiring state fails, the pre-required state will not execute.
If the "changes" key contains an empty dictionary, this means that changes are not expected by the pre-required state. Neither the pre-required state nor the pre-requiring state will run.
The fact is that the pre-required state always runs whether there's any change or not.
The pre-requiring state only runs if changes are expected.
Lets make some clarification with the confusing terms used here:
test-a:
salt.function:
- name: service.stop
- tgt: minion1
- arg:
- myservice
- prereq:
- test-b
test-b:
salt.state:
- tgt: minion1
- sls:
- mystate
In this example, test-a is the pre-requiring state, test-b is the pre-required state.
What happens it that test-b always run twice whether changes are expected or not.
Under normal situations, this doesn't hurt anything, but it would cause serious problem if test-a fail to generate changes in test mode, as in #49753 .
I know that the pchanges issue has already been fixed, but it would be nice to make prereq work as expected, or at least update the documentation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the test-a/test-b example to trace prereq execution and compare the documented populated-versus-empty changes behavior with the actual runs. Review the related pchanges fix and issue #49753 for context. Done means prereq states follow the documented execution rules, with coverage for both changes cases, or the documentation accurately describes the retained behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100