Skip to content

[FEATURE REQUEST] Add failhard kwarg for state.apply #58608

@oeuftete

Description

@oeuftete

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Featurenew functionality including changes to functionality and code refactors, etc.ZDThe issue is related to a Zendesk customer support ticket.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions