Commit 3c631ea2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

jqueue: Don't modify input opcode when changing priority

Commit 4679547e

 implemented the ability to change job's priority after it
was submitted. The code contained a bug whereby it would modify the
input data for an opcode, something the job queue shouldn't do (logical
units do for historical reasons).

This patch removes the line modifying the opcode input and adjusts the
tests.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent ca519248
......@@ -517,9 +517,7 @@ class _QueuedJob(object):
changed = True
# Note: this also changes the on-disk priority ("op.priority" is only in
# memory)
op.input.priority = priority
# Set new priority (doesn't modify opcode input)
op.priority = priority
if changed:
......
......@@ -398,7 +398,8 @@ class TestQueuedJob(unittest.TestCase):
result = job.ChangePriority(-10)
self.assertEqual(job.CalcPriority(), -10)
self.assertTrue(compat.all(op.priority == -10 for op in job.ops))
self.assertTrue(compat.all(op.input.priority == -10 for op in job.ops))
self.assertFalse(compat.any(hasattr(op.input, "priority")
for op in job.ops))
self.assertEqual(result,
(True, ("Priorities of pending opcodes for job 24984 have"
" been changed to -10")))
......@@ -468,8 +469,8 @@ class TestQueuedJob(unittest.TestCase):
self.assertEqual(job.CalcPriority(), constants.OP_PRIO_DEFAULT)
self.assertEqual(map(operator.attrgetter("priority"), job.ops),
[constants.OP_PRIO_DEFAULT, 7, 7, 7])
self.assertEqual([getattr(op.input, "priority", None) for op in job.ops],
[None, 7, 7, 7])
self.assertFalse(compat.any(hasattr(op.input, "priority")
for op in job.ops))
self.assertEqual(map(operator.attrgetter("status"), job.ops), [
constants.OP_STATUS_RUNNING,
constants.OP_STATUS_QUEUED,
......@@ -520,8 +521,8 @@ class TestQueuedJob(unittest.TestCase):
self.assertEqual(map(operator.attrgetter("priority"), job.ops),
[constants.OP_PRIO_DEFAULT, constants.OP_PRIO_DEFAULT,
-19, -19])
self.assertEqual([getattr(op.input, "priority", None) for op in job.ops],
[None, None, -19, -19])
self.assertFalse(compat.any(hasattr(op.input, "priority")
for op in job.ops))
self.assertEqual(map(operator.attrgetter("status"), job.ops), [
constants.OP_STATUS_SUCCESS,
constants.OP_STATUS_RUNNING,
......@@ -2221,6 +2222,10 @@ class TestJobProcessorTimeouts(unittest.TestCase, _JobProcessorTestUtils):
result = proc(_nextop_fn=self._NextOpcode)
assert self.curop is not None
# Input priority should never be set or modified
self.assertFalse(compat.any(hasattr(op.input, "priority")
for op in job.ops))
if result == jqueue._JobProcessor.FINISHED or self.gave_lock:
# Got lock and/or job is done, result must've been written
self.assertFalse(job.cur_opctx)
......
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