Commit 963a068b authored by Michael Hanselmann's avatar Michael Hanselmann

jqueue: Mark opcodes following failed ones as failed, too

When an opcode fails, the job queue would leave following opcodes as “queued”,
which can be quite confusing. With this patch, they're all marked as failed and
assertions are added to check this.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 6ea72e43
...@@ -757,6 +757,11 @@ class _JobQueueWorker(workerpool.BaseWorker): ...@@ -757,6 +757,11 @@ class _JobQueueWorker(workerpool.BaseWorker):
if idx == count - 1: if idx == count - 1:
job.lock_status = None job.lock_status = None
job.end_timestamp = TimeStampNow() job.end_timestamp = TimeStampNow()
# Consistency check
assert compat.all(i.status == constants.OP_STATUS_SUCCESS
for i in job.ops)
queue.UpdateJobUnlocked(job) queue.UpdateJobUnlocked(job)
finally: finally:
queue.release() queue.release()
...@@ -780,6 +785,17 @@ class _JobQueueWorker(workerpool.BaseWorker): ...@@ -780,6 +785,17 @@ class _JobQueueWorker(workerpool.BaseWorker):
op.end_timestamp = TimeStampNow() op.end_timestamp = TimeStampNow()
logging.info("Op %s/%s: Error in opcode %s: %s", logging.info("Op %s/%s: Error in opcode %s: %s",
idx + 1, count, op_summary, err) idx + 1, count, op_summary, err)
to_encode = errors.OpExecError("Preceding opcode failed")
job.MarkUnfinishedOps(constants.OP_STATUS_ERROR,
errors.EncodeException(to_encode))
# Consistency check
assert compat.all(i.status == constants.OP_STATUS_SUCCESS
for i in job.ops[:idx])
assert compat.all(i.status == constants.OP_STATUS_ERROR and
errors.GetEncodedError(i.result)
for i in job.ops[idx:])
finally: finally:
job.lock_status = None job.lock_status = None
job.end_timestamp = TimeStampNow() job.end_timestamp = TimeStampNow()
......
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