mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fixed nested orchestrate not respecting failures
Client was only setting success to false if the function called raised an exception. This commit changes it to verify the content of return value with check_state_result
This commit is contained in:
parent
ecd441d090
commit
266e0a465c
4 changed files with 32 additions and 0 deletions
|
@ -394,6 +394,8 @@ class SyncClientMixin(object):
|
|||
with tornado.stack_context.StackContext(self.functions.context_dict.clone):
|
||||
data['return'] = self.functions[fun](*args, **kwargs)
|
||||
data['success'] = True
|
||||
if 'data' in data['return']:
|
||||
data['success'] = salt.utils.check_state_result(data['return']['data'])
|
||||
except (Exception, SystemExit) as ex:
|
||||
if isinstance(ex, salt.exceptions.NotImplemented):
|
||||
data['return'] = str(ex)
|
||||
|
|
6
tests/integration/files/file/base/nested-orch/inner.sls
Executable file
6
tests/integration/files/file/base/nested-orch/inner.sls
Executable file
|
@ -0,0 +1,6 @@
|
|||
cmd.run:
|
||||
salt.function:
|
||||
- tgt: minion
|
||||
- arg:
|
||||
- /bin/false
|
||||
- failhard: True
|
10
tests/integration/files/file/base/nested-orch/outer.sls
Executable file
10
tests/integration/files/file/base/nested-orch/outer.sls
Executable file
|
@ -0,0 +1,10 @@
|
|||
state.orchestrate:
|
||||
salt.runner:
|
||||
- mods: nested-orch.inner
|
||||
- failhard: True
|
||||
|
||||
cmd.run:
|
||||
salt.function:
|
||||
- tgt: minion
|
||||
- arg:
|
||||
- touch /tmp/ewu-2016-12-13
|
|
@ -68,6 +68,20 @@ class StateRunnerTest(integration.ShellCase):
|
|||
for item in good_out:
|
||||
self.assertIn(item, ret_output)
|
||||
|
||||
def test_orchestrate_nested(self):
|
||||
'''
|
||||
test salt-run state.orchestrate and failhard with nested orchestration
|
||||
'''
|
||||
if os.path.exists('/tmp/ewu-2016-12-13'):
|
||||
os.remove('/tmp/ewu-2016-12-13')
|
||||
|
||||
_, code = self.run_run(
|
||||
'state.orchestrate nested-orch.outer',
|
||||
with_retcode=True)
|
||||
|
||||
self.assertFalse(os.path.exists('/tmp/ewu-2016-12-13'))
|
||||
self.assertNotEqual(code, 0)
|
||||
|
||||
def test_state_event(self):
|
||||
'''
|
||||
test to ensure state.event
|
||||
|
|
Loading…
Add table
Reference in a new issue