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:
Elias Wulcan 2016-12-14 14:41:03 +01:00
parent ecd441d090
commit 266e0a465c
4 changed files with 32 additions and 0 deletions

View file

@ -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)

View file

@ -0,0 +1,6 @@
cmd.run:
salt.function:
- tgt: minion
- arg:
- /bin/false
- failhard: True

View 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

View file

@ -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