[FEATURE REQUEST] Add failhard kwarg for state.apply
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Is your feature request related to a problem? Please describe.
I'd like to be able to make use of something like the global failhard on an on-demand basis with state.apply.
Describe the solution you'd like
Add a kwarg to state.apply. E.g. something like:
salt-call state.apply partially.failing.state failhard=True
Additional context
Related
- https://github.com/saltstack/salt/issues/55697: --fail-hard for salt-ssh
Example
Some examples from 3001.1 to demonstrate current behaviour, using a state with two failures:
Base case:
[root@master1 /]# salt --state-output terse master1 state.apply test.failure
master1:
Name: test-fail-without-changes - Function: test.fail_without_changes - Result: Failed Started: - 17:30:54.116673 Duration: 0.633 ms
Name: test-fail-with-changes - Function: test.fail_with_changes - Result: Failed Started: - 17:30:54.125297 Duration: 0.614 ms
Summary for master1
------------
Succeeded: 0 (changed=1)
Failed: 2
------------
Total states run: 2
Total run time: 1.247 ms
ERROR: Minions returned with non-zero exit code
Adding kwarg (does nothing at the moment):
[root@master1 /]# salt --state-output terse master1 state.apply test.failure failhard=True
master1:
Name: test-fail-without-changes - Function: test.fail_without_changes - Result: Failed Started: - 17:30:57.661318 Duration: 0.55 ms
Name: test-fail-with-changes - Function: test.fail_with_changes - Result: Failed Started: - 17:30:57.669760 Duration: 0.588 ms
Summary for master1
------------
Succeeded: 0 (changed=1)
Failed: 2
------------
Total states run: 2
Total run time: 1.138 ms
ERROR: Minions returned with non-zero exit code
Setting global option, fails hard as expected:
[root@master1 /]# echo 'failhard: True' > /etc/salt/master.d/failhard.conf
[root@master1 /]# systemctl restart salt-master
[root@master1 /]# salt --state-output terse master1 state.apply test.failure
master1:
Name: test-fail-without-changes - Function: test.fail_without_changes - Result: Failed Started: - 17:33:36.635219 Duration: 0.579 ms
Summary for master1
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 0.579 ms
ERROR: Minions returned with non-zero exit code
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
Start at the state.apply entry point and trace how the global failhard option stops execution. Compare the requested failhard=True invocation with the current default behavior and the related salt-ssh issue. Done means state.apply accepts the kwarg, stops after the first failure when enabled, and preserves current behavior otherwise.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100