mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Updating function in saltmod to ensure that the result is a failure if the function being run returns as False.
This commit is contained in:
parent
c4d828c986
commit
377e34c689
@ -581,6 +581,9 @@ def function(
|
||||
m_ret = mdata['ret']
|
||||
m_func = (not fail_function and True) or __salt__[fail_function](m_ret)
|
||||
|
||||
if m_ret is False:
|
||||
m_func = False
|
||||
|
||||
if not m_func:
|
||||
if minion not in fail_minions:
|
||||
fail.add(minion)
|
||||
|
@ -257,6 +257,32 @@ class StateRunnerTest(ShellCase):
|
||||
self.assertEqual(count('Succeeded: 1', ret), 1)
|
||||
self.assertEqual(count('Failed: 0', ret), 1)
|
||||
|
||||
def test_orchestrate_salt_function_return_false_failure(self):
|
||||
'''
|
||||
Ensure that functions that only return False in the return
|
||||
are flagged as failed when run as orchestrations.
|
||||
|
||||
See https://github.com/saltstack/salt/issues/30367
|
||||
'''
|
||||
self.run_run('saltutil.sync_modules')
|
||||
ret = salt.utils.json.loads(
|
||||
'\n'.join(
|
||||
self.run_run('state.orchestrate orch.issue30367 --out=json')
|
||||
)
|
||||
)
|
||||
# Drill down to the changes dict
|
||||
state_result = ret['data']['master']['salt_|-deploy_check_|-test.false_|-function']['result']
|
||||
func_ret = ret['data']['master']['salt_|-deploy_check_|-test.false_|-function']['changes']
|
||||
|
||||
self.assertEqual(
|
||||
state_result,
|
||||
False,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
func_ret,
|
||||
{'out': 'highstate', 'ret': {'minion': False}}
|
||||
)
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), '*NIX-only test')
|
||||
class OrchEventTest(ShellCase):
|
||||
|
Loading…
Reference in New Issue
Block a user