bail out on error in async command marked as fail

When executing async commands, bail out in case the fail flag is set
and a command returns a non zero exit code. This is required to
ensure that further downstream commands are not executed as well.

Previously, the execution continued till the first error of the command
execution itself happened (e.g. command not found).

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Felix Moessbauer 2023-05-08 10:17:40 +02:00 committed by Jan Kiszka
parent b21a7e1c3b
commit ac43730889

View File

@ -156,6 +156,7 @@ async def run_cmd_async(cmd, cwd, env=None, fail=True, liveupdate=True):
for line in logo.stderr: for line in logo.stderr:
msg += line msg += line
logging.error(msg) logging.error(msg)
raise CommandExecError(cmd, ret)
return (ret, ''.join(logo.stdout)) return (ret, ''.join(logo.stdout))