From e6345c3555e08f43e02a39a468a04da380d13737 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 27 Aug 2009 15:02:50 +0200 Subject: [PATCH] Encode the actual exception raised by LU execution Currently, the actual exception raised during an LU execution (one of OpPrereqError, OpExecError, HooksError, etc.) is lost because the jqueue.py code simply sets that to a str(err), and the code in cli.py simply passes that string to OpExecError. This patch moves to encoding the errors as per errors.EncodeError and changes the cli code to parse and raise that (if possible). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> (cherry picked from commit bcb66fcabfb31ac63beebcc2249bbb8cb30703ae) --- lib/cli.py | 1 + lib/jqueue.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cli.py b/lib/cli.py index 8ba71988e..95f3cc9b9 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -572,6 +572,7 @@ def PollJob(job_id, cl=None, feedback_fn=None): if status == constants.OP_STATUS_SUCCESS: has_ok = True elif status == constants.OP_STATUS_ERROR: + errors.MaybeRaise(msg) if has_ok: raise errors.OpExecError("partial failure (opcode %d): %s" % (idx, msg)) diff --git a/lib/jqueue.py b/lib/jqueue.py index 9219caede..5113434c8 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -460,7 +460,10 @@ class _JobQueueWorker(workerpool.BaseWorker): try: try: op.status = constants.OP_STATUS_ERROR - op.result = str(err) + if isinstance(err, errors.GenericError): + op.result = errors.EncodeException(err) + else: + op.result = str(err) op.end_timestamp = TimeStampNow() logging.info("Op %s/%s: Error in opcode %s: %s", idx + 1, count, op_summary, err) -- GitLab