mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #6235 from terminalmage/issue6230
Report on cache failures for cmd.script states
This commit is contained in:
commit
200de9c726
@ -694,11 +694,23 @@ def script(
|
||||
path = salt.utils.mkstemp(dir=cwd)
|
||||
else:
|
||||
path = __salt__['cp.cache_file'](source, env)
|
||||
if not path:
|
||||
return {'pid': 0,
|
||||
'retcode': 1,
|
||||
'stdout': '',
|
||||
'stderr': '',
|
||||
'cache_error': True}
|
||||
if template:
|
||||
__salt__['cp.get_template'](source, path, template, env, **kwargs)
|
||||
else:
|
||||
if not salt.utils.is_windows():
|
||||
fn_ = __salt__['cp.cache_file'](source, env)
|
||||
if not fn_:
|
||||
return {'pid': 0,
|
||||
'retcode': 1,
|
||||
'stdout': '',
|
||||
'stderr': '',
|
||||
'cache_error': True}
|
||||
shutil.copyfile(fn_, path)
|
||||
if not salt.utils.is_windows():
|
||||
os.chmod(path, 320)
|
||||
|
@ -641,7 +641,7 @@ def script(name,
|
||||
# Wow, we passed the test, run this sucker!
|
||||
try:
|
||||
cmd_all = __salt__['cmd.script'](source, **cmd_kwargs)
|
||||
except CommandExecutionError as err:
|
||||
except (CommandExecutionError, IOError) as err:
|
||||
ret['comment'] = str(err)
|
||||
return ret
|
||||
|
||||
@ -650,7 +650,11 @@ def script(name,
|
||||
ret['result'] = not bool(cmd_all)
|
||||
else:
|
||||
ret['result'] = not bool(cmd_all['retcode'])
|
||||
ret['comment'] = 'Command "{0}" run'.format(name)
|
||||
if ret.get('changes', {}).get('cache_error'):
|
||||
ret['comment'] = 'Unable to cache script {0} from env ' \
|
||||
'\'{1}\''.format(source, env)
|
||||
else:
|
||||
ret['comment'] = 'Command "{0}" run'.format(name)
|
||||
return _reinterpreted_state(ret) if stateful else ret
|
||||
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user