Commit d2c8afb1 authored by Michael Hanselmann's avatar Michael Hanselmann

jqueue: Don't return negative number for unchecked jobs when archiving

When the queue was empty, the calculation for unchecked jobs while
archiving would return -1. ``last_touched`` is set to 0, the job ID list
(``all_job_ids``) is empty. Calculating ``len(all_job_ids) -
last_touched - 1`` resulted in -1.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 9fe72672
......@@ -1321,7 +1321,7 @@ class JobQueue(object):
all_job_ids = self._GetJobIDsUnlocked(archived=False)
pending = []
for idx, job_id in enumerate(all_job_ids):
last_touched = idx
last_touched = idx + 1
# Not optimal because jobs could be pending
# TODO: Measure average duration for job archival and take number of
......@@ -1351,7 +1351,7 @@ class JobQueue(object):
if pending:
archived_count += self._ArchiveJobsUnlocked(pending)
return (archived_count, len(all_job_ids) - last_touched - 1)
return (archived_count, len(all_job_ids) - last_touched)
@staticmethod
def _GetJobInfoUnlocked(job, fields):
......
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