Commit abe362d3 authored by Michael Hanselmann's avatar Michael Hanselmann Committed by Iustin Pop
Browse files

Fix error in opcode result processing

LUXI queries are processed without callbacks (see
server.masterd.ClientOps._Query). With commit 07923a3c

 the logic for
checking an opcode's result for jobs to submit was changed and
subsequently raised an exception (“'NoneType' object has no attribute
'SubmitManyJobs'”) in such a case. Before said commit the exception
would also have been raised if an opcode used by a query submitted jobs.

This patch changes the logic to only resolve the method if callbacks are
defined and to use an exception-raising implementation otherwise.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 96897af7
...@@ -220,6 +220,14 @@ def _ProcessResult(submit_fn, op, result): ...@@ -220,6 +220,14 @@ def _ProcessResult(submit_fn, op, result):
return result return result
def _FailingSubmitManyJobs(_):
"""Implementation of L{OpExecCbBase.SubmitManyJobs} to raise an exception.
raise errors.ProgrammerError("Opcodes processed without callbacks (e.g."
" queries) can not submit jobs")
def _RpcResultsToHooksResults(rpc_results): def _RpcResultsToHooksResults(rpc_results):
"""Function to convert RPC results to the format expected by HooksMaster. """Function to convert RPC results to the format expected by HooksMaster.
...@@ -299,9 +307,13 @@ class Processor(object): ...@@ -299,9 +307,13 @@ class Processor(object):
" the operation") " the operation")
return lu.dry_run_result return lu.dry_run_result
if self._cbs:
submit_mj_fn = self._cbs.SubmitManyJobs
submit_mj_fn = _FailingSubmitManyJobs
try: try:
result = _ProcessResult(self._cbs.SubmitManyJobs, lu.op, result = _ProcessResult(submit_mj_fn, lu.op, lu.Exec(self.Log))
h_results = hm.RunPhase(constants.HOOKS_PHASE_POST) h_results = hm.RunPhase(constants.HOOKS_PHASE_POST)
result = lu.HooksCallBack(constants.HOOKS_PHASE_POST, h_results, result = lu.HooksCallBack(constants.HOOKS_PHASE_POST, h_results,
self.Log, result) self.Log, result)
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