Skip to content

Commit

Permalink
Remove _check_ret calls since they're not needed anymore
Browse files Browse the repository at this point in the history
after #64542 was merged
  • Loading branch information
lkubb authored and dwoz committed Jan 2, 2024
1 parent d3a113f commit 982ffba
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions salt/client/ssh/wrapper/cmdmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,9 @@ def script(
salt '*' cmd.script salt://scripts/runme.sh stdin='one\\ntwo\\nthree\\nfour\\nfive\\n'
"""

def _check_ret(ret):
# Failing unwrapped calls to the minion always return a result dict
# and do not throw exceptions currently.
if isinstance(ret, dict) and ret.get("stderr"):
raise CommandExecutionError(ret["stderr"])

def _cleanup_tempfile(path):
try:
_check_ret(__salt__["file.remove"](path))
__salt__["file.remove"](path)
except (SaltInvocationError, CommandExecutionError) as exc:
log.error(
"cmd.script: Unable to clean tempfile '%s': %s",
Expand All @@ -253,7 +247,6 @@ def _cleanup_tempfile(path):
path = __salt__["temp.file"](
suffix=os.path.splitext(salt.utils.url.split_env(source)[0])[1], parent=cwd
)
_check_ret(path)
try:
if template:
if "pillarenv" in kwargs or "pillar" in kwargs:
Expand All @@ -280,11 +273,9 @@ def _cleanup_tempfile(path):
"stderr": "",
"cache_error": True,
}
_check_ret(__salt__["file.copy"](fn_, path))
_check_ret(__salt__["file.set_mode"](path, "0500"))
uid = __salt__["file.user_to_uid"](runas)
_check_ret(uid)
_check_ret(__salt__["file.chown"](path, runas, -1))
__salt__["file.copy"](fn_, path)
__salt__["file.set_mode"](path, "0500")
__salt__["file.chown"](path, runas, -1)

cmd_path = shlex.quote(path)
# We should remove the pillar from kwargs (cmd.run_all ignores it anyways)
Expand Down

0 comments on commit 982ffba

Please sign in to comment.