Show simple error string, when subprocess batch actions fail

logs still have more info, can't show user the whole traceback..but
this is better than we had before..
This commit is contained in:
Lance Edgar 2022-12-08 14:15:38 -06:00
parent cea06c9673
commit f80d3cd530

View file

@ -963,12 +963,15 @@ class BatchMasterView(MasterView):
# run command in subprocess
log.debug("launching command in subprocess: %s", cmd)
try:
subprocess.check_output(cmd, stderr=subprocess.PIPE)
# nb. we do not capture stderr, but on failure the stdout
# will contain a simple error string
subprocess.check_output(cmd)
except subprocess.CalledProcessError as error:
log.warning("command failed with exit code %s! output was:",
error.returncode)
log.warning(error.stderr.decode('utf_8'))
raise
output = error.output.decode('utf_8')
log.warning(output)
raise Exception(output)
def action_subprocess_thread(self, key, port, username, handler_action, progress, **kwargs):
"""
@ -1009,8 +1012,8 @@ class BatchMasterView(MasterView):
progress.session.load()
progress.session['error'] = True
progress.session['error_msg'] = (
"{} of '{}' batch failed (see logs for more info)").format(
handler_action, self.handler.batch_key)
"{} of '{}' batch failed: {} (see logs for more info)").format(
handler_action, self.handler.batch_key, error)
progress.session.save()
return