Commit aa9f8167 authored by Iustin Pop's avatar Iustin Pop

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 78bb78b1
......@@ -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)
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment