Commit adfa97e3 authored by Guido Trotter's avatar Guido Trotter

Processor: support a unique execution id

When the processor is executing a job, it can export the execution id to
its callers. This is not supported for Queries, as they're not executed
in a job.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 664fbc9d
......@@ -322,7 +322,8 @@ class ClientOps:
"""Runs the specified opcode and returns the result.
"""
proc = mcpu.Processor(self.server.context)
# Queries don't have a job id
proc = mcpu.Processor(self.server.context, None)
return proc.ExecOpCode(op, None)
......
......@@ -431,7 +431,7 @@ class _JobQueueWorker(workerpool.BaseWorker):
"""
logging.info("Worker %s processing job %s",
self.worker_id, job.id)
proc = mcpu.Processor(self.pool.queue.context)
proc = mcpu.Processor(self.pool.queue.context, job.id)
queue = job.queue
try:
try:
......
......@@ -222,11 +222,17 @@ class Processor(object):
opcodes.OpTestAllocator: cmdlib.LUTestAllocator,
}
def __init__(self, context):
def __init__(self, context, ec_id):
"""Constructor for Processor
@type context: GanetiContext
@param context: global Ganeti context
@type ec_id: string
@param ec_id: execution context identifier
"""
self.context = context
self._ec_id = ec_id
self._cbs = None
self.rpc = rpc.RpcRunner(context.cfg)
self.hmclass = HooksMaster
......@@ -501,6 +507,11 @@ class Processor(object):
logging.info(message)
self._Feedback(" - INFO: %s" % message)
def GetECId(self):
if not self._ec_id:
errors.ProgrammerError("Tried to use execution context id when not set")
return self._ec_id
class HooksMaster(object):
"""Hooks master.
......
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