Backporting #47843 to 2017.7, updating test for 2017.7.

This commit is contained in:
Gareth J. Greenaway 2018-06-05 14:27:52 -07:00
parent 998a1c13d5
commit 54e51bc627
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41
2 changed files with 24 additions and 0 deletions

View file

@ -519,6 +519,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)

View file

@ -168,6 +168,27 @@ 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']
self.assertEqual(
state_result,
False,
)
@skipIf(salt.utils.is_windows(), '*NIX-only test')
class OrchEventTest(ShellCase):