Commit e71c8147 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

jqueue: Ensure only accepted priorities are allowed for submitting jobs

Quoting the design document: “Submitted opcodes can have one of the priorities
listed below. Other priorities are reserved for internal use”. Submitting jobs
at priority -20 should not be allowed.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 8f5c488d
......@@ -849,6 +849,12 @@ OP_PRIO_LOW = +10
OP_PRIO_SUBMIT_VALID = frozenset([
# Execution log types
......@@ -1370,6 +1370,7 @@ class JobQueue(object):
@return: the job object to be queued
@raise errors.JobQueueDrainError: if the job queue is marked for draining
@raise errors.JobQueueFull: if the job queue has too many jobs in it
@raise errors.GenericError: If an opcode is not valid
# Ok when sharing the big job queue lock, as the drain file is created when
......@@ -1382,6 +1383,13 @@ class JobQueue(object):
job = _QueuedJob(self, job_id, ops)
# Check priority
for idx, op in enumerate(job.ops):
if op.priority not in constants.OP_PRIO_SUBMIT_VALID:
allowed = utils.CommaJoin(constants.OP_PRIO_SUBMIT_VALID)
raise errors.GenericError("Opcode %s has invalid priority %s, allowed"
" are %s" % (idx, op.priority, allowed))
# Write to disk
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