From 4c91d2ad7a4addc4c6e73f07c27456c9954b927e Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 31 Oct 2012 14:47:18 +0100 Subject: [PATCH] Improve logging of new job submissions This addresses issue 290: when receiving new jobs, logging is incomplete, and we don't have the job ID(s) and/or summaries logged. Only later, when the job is queried for or being processed, we know more. This is not good when troubleshooting, so let's improve the initial logging. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Bernardo Dal Seno <bdalseno@google.com> --- lib/server/masterd.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/server/masterd.py b/lib/server/masterd.py index 71ddb90b5..40917fe4d 100644 --- a/lib/server/masterd.py +++ b/lib/server/masterd.py @@ -66,6 +66,18 @@ EXIT_NOTMASTER = constants.EXIT_NOTMASTER EXIT_NODESETUP_ERROR = constants.EXIT_NODESETUP_ERROR +def _LogNewJob(status, info, ops): + """Log information about a recently submitted job. + + """ + if status: + logging.info("New job with id %s, summary: %s", + info, utils.CommaJoin(op.Summary() for op in ops)) + else: + logging.info("Failed to submit job, reason: '%s', summary: %s", + info, utils.CommaJoin(op.Summary() for op in ops)) + + class ClientRequestWorker(workerpool.BaseWorker): # pylint: disable=W0221 def RunTask(self, server, message, client): @@ -267,18 +279,23 @@ class ClientOps: # TODO: Rewrite to not exit in each 'if/elif' branch if method == luxi.REQ_SUBMIT_JOB: - logging.info("Received new job") + logging.info("Receiving new job") (job_def, ) = args ops = [opcodes.OpCode.LoadOpCode(state) for state in job_def] - return queue.SubmitJob(ops) + job_id = queue.SubmitJob(ops) + _LogNewJob(True, job_id, ops) + return job_id elif method == luxi.REQ_SUBMIT_MANY_JOBS: - logging.info("Received multiple jobs") + logging.info("Receiving multiple jobs") (job_defs, ) = args jobs = [] for ops in job_defs: jobs.append([opcodes.OpCode.LoadOpCode(state) for state in ops]) - return queue.SubmitManyJobs(jobs) + job_ids = queue.SubmitManyJobs(jobs) + for ((status, job_id), ops) in zip(job_ids, jobs): + _LogNewJob(status, job_id, ops) + return job_ids elif method == luxi.REQ_CANCEL_JOB: (job_id, ) = args -- GitLab