From 169f0dee7095f2e2cf4d9a2fca5fde9d16edb776 Mon Sep 17 00:00:00 2001 From: wwade Date: Fri, 9 Sep 2022 10:41:31 -0700 Subject: [PATCH 1/2] utils: add missing log level to killProcGroup debug trace There was a missing function name to indicate the log level. This one should be at the "debug" level since we tend to need to run the kill commands a few times to stick. --- jobrunner/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobrunner/utils.py b/jobrunner/utils.py index 75c615e..e7f3738 100644 --- a/jobrunner/utils.py +++ b/jobrunner/utils.py @@ -348,7 +348,7 @@ def sudoKillProcGroup(pgrp): try: subprocess.check_call(cmd) except subprocess.CalledProcessError as error: - LOG("cmd %r => error=%s", cmd, error, exc_info=True) + LOG.debug("cmd %r => error=%s", cmd, error, exc_info=True) return error.output return None From aeca486ef5685b474284508076b7b8469be7d143 Mon Sep 17 00:00:00 2001 From: wwade Date: Sat, 10 Sep 2022 11:26:23 -0700 Subject: [PATCH 2/2] mail: handle autoDecode failure for job logs with binary data I ran a command that wrote a tarball into the job log file and so it couldn't be decoded as utf-8. It subsequently caused autoDecode to fail with a UnicodeDecodeError. ValueError is an ancestor of UnicodeDecodeError and would hopefully cover other decoding errors for other encodings as well. --- jobrunner/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jobrunner/main.py b/jobrunner/main.py index 24d5cc8..2d85c1b 100755 --- a/jobrunner/main.py +++ b/jobrunner/main.py @@ -799,7 +799,13 @@ def extendMailOrNotifyCmdLockRequired( safeWrite(tmp, depJob.detail(False)) safeWrite(tmp, "\n" + SPACER_EACH + "\n") assert depJob.logfile - lines = autoDecode(check_output(["tail", "-n20", depJob.logfile])) + out = check_output(["tail", "-n20", depJob.logfile]) + try: + lines = autoDecode(out) + except ValueError as err: + LOG.debug("error decoding output from log file %r for %s: %s", + depJob.logfile, depJob, err) + lines = f"{out[:50]}\n" safeWrite(tmp, lines) safeWrite(tmp, SPACER_EACH + "\n") safeWrite(tmp, "\n")