From aa9f81678bc1f68f2cf2007397ce352b674d4ba8 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 29 Jul 2010 19:00:19 -0400 Subject: [PATCH] Fix a few job archival issues This patch fixes two issues with job archival. First, the LoadJobFromDisk can return 'None' for no-such-job, and we shouldn't add None to the job list; we can't anyway, as this raises an exception: node1# gnt-job archive foo Unhandled protocol error while talking to the master daemon: Caught exception: cannot create weak reference to 'NoneType' object After fixing this, job archival of missing jobs will just continue silently, so we modify gnt-job archive to log jobs which were not archived and to return exit code 1 for any missing jobs. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/jqueue.py | 2 ++ scripts/gnt-job | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/jqueue.py b/lib/jqueue.py index f27eba688..ebb6bf759 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -1194,6 +1194,8 @@ class JobQueue(object): try: job = self._LoadJobFromDisk(job_id) + if job is None: + return job except errors.JobFileCorrupted: old_path = self._GetJobPath(job_id) new_path = self._GetArchivedJobPath(job_id) diff --git a/scripts/gnt-job b/scripts/gnt-job index a174200f2..2e71baea1 100755 --- a/scripts/gnt-job +++ b/scripts/gnt-job @@ -134,10 +134,13 @@ def ArchiveJobs(opts, args): """ client = GetClient() + rcode = 0 for job_id in args: - client.ArchiveJob(job_id) + if not client.ArchiveJob(job_id): + ToStderr("Failed to archive job with ID '%s'", job_id) + rcode = 1 - return 0 + return rcode def AutoArchiveJobs(opts, args): -- GitLab