From 0e050889f5da9345b5a6c978c469fc46ad3b04e3 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 27 Nov 2008 03:12:31 +0000 Subject: [PATCH] Small change to job failure output Currently, job failures are done by raising OpExecError(job result). For a one-opcode job that failed, this is very non-intuitive: Failure: command execution error: [u'Disk size change not possible, use grow-disk'] This patch changes the output in two ways: - for a job which didn't have opcodes which succeeded, it changes it to: Failure: command execution error: Disk size change not possible, use grow-disk - for a job with partial completion, to: Failure: command execution error: partial failure (opcode 1): Cannot remove the last disk of an instance The actual error type is not changed. A job that doesn't have at least an error-ed opcode is shown as before. Reviewed-by: imsnah --- lib/cli.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index 39a080b34..698427c48 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -565,14 +565,25 @@ def PollJob(job_id, cl=None, feedback_fn=None): prev_job_info = job_info - jobs = cl.QueryJobs([job_id], ["status", "opresult"]) + jobs = cl.QueryJobs([job_id], ["status", "opstatus", "opresult"]) if not jobs: raise errors.JobLost("Job with id %s lost" % job_id) - status, result = jobs[0] + status, opstatus, result = jobs[0] if status == constants.JOB_STATUS_SUCCESS: return result else: + has_ok = False + for idx, (status, msg) in enumerate(zip(opstatus, result)): + if status == constants.OP_STATUS_SUCCESS: + has_ok = True + elif status == constants.OP_STATUS_ERROR: + if has_ok: + raise errors.OpExecError("partial failure (opcode %d): %s" % + (idx, msg)) + else: + raise errors.OpExecError(str(msg)) + # default failure mode raise errors.OpExecError(result) -- GitLab