mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Report on cache failures for cmd.script states
This commit will report that the source script failed to cache, rather than misreporting that the script was run when it couldn't possibly have run.
This commit is contained in:
parent
d38860ee8c
commit
085f9a98b6
@ -694,11 +694,23 @@ def script(
|
|||||||
path = salt.utils.mkstemp(dir=cwd)
|
path = salt.utils.mkstemp(dir=cwd)
|
||||||
else:
|
else:
|
||||||
path = __salt__['cp.cache_file'](source, env)
|
path = __salt__['cp.cache_file'](source, env)
|
||||||
|
if not path:
|
||||||
|
return {'pid': 0,
|
||||||
|
'retcode': 1,
|
||||||
|
'stdout': '',
|
||||||
|
'stderr': '',
|
||||||
|
'cache_error': True}
|
||||||
if template:
|
if template:
|
||||||
__salt__['cp.get_template'](source, path, template, env, **kwargs)
|
__salt__['cp.get_template'](source, path, template, env, **kwargs)
|
||||||
else:
|
else:
|
||||||
if not salt.utils.is_windows():
|
if not salt.utils.is_windows():
|
||||||
fn_ = __salt__['cp.cache_file'](source, env)
|
fn_ = __salt__['cp.cache_file'](source, env)
|
||||||
|
if not fn_:
|
||||||
|
return {'pid': 0,
|
||||||
|
'retcode': 1,
|
||||||
|
'stdout': '',
|
||||||
|
'stderr': '',
|
||||||
|
'cache_error': True}
|
||||||
shutil.copyfile(fn_, path)
|
shutil.copyfile(fn_, path)
|
||||||
if not salt.utils.is_windows():
|
if not salt.utils.is_windows():
|
||||||
os.chmod(path, 320)
|
os.chmod(path, 320)
|
||||||
|
@ -641,7 +641,7 @@ def script(name,
|
|||||||
# Wow, we passed the test, run this sucker!
|
# Wow, we passed the test, run this sucker!
|
||||||
try:
|
try:
|
||||||
cmd_all = __salt__['cmd.script'](source, **cmd_kwargs)
|
cmd_all = __salt__['cmd.script'](source, **cmd_kwargs)
|
||||||
except CommandExecutionError as err:
|
except (CommandExecutionError, IOError) as err:
|
||||||
ret['comment'] = str(err)
|
ret['comment'] = str(err)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -650,7 +650,11 @@ def script(name,
|
|||||||
ret['result'] = not bool(cmd_all)
|
ret['result'] = not bool(cmd_all)
|
||||||
else:
|
else:
|
||||||
ret['result'] = not bool(cmd_all['retcode'])
|
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
|
return _reinterpreted_state(ret) if stateful else ret
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user