Revision 96cb3986 daemons/ganeti-masterd
b/daemons/ganeti-masterd | ||
---|---|---|
36 | 36 |
import random |
37 | 37 |
import signal |
38 | 38 |
import simplejson |
39 |
|
|
39 |
import logging |
|
40 | 40 |
|
41 | 41 |
from cStringIO import StringIO |
42 | 42 |
from optparse import OptionParser |
... | ... | |
51 | 51 |
from ganeti import utils |
52 | 52 |
from ganeti import errors |
53 | 53 |
from ganeti import ssconf |
54 |
from ganeti import logger |
|
54 | 55 |
|
55 | 56 |
|
56 | 57 |
EXIT_NOTMASTER = constants.EXIT_NOTMASTER |
... | ... | |
144 | 145 |
for i in range(self.QUEUE_PROCESSOR_SIZE): |
145 | 146 |
self.queue.new_queue.put(None) |
146 | 147 |
for idx, t in enumerate(self.processors): |
147 |
print "waiting for processor thread %s..." % idx
|
|
148 |
logging.debug("waiting for processor thread %s...", idx)
|
|
148 | 149 |
t.join() |
149 |
print "done threads"
|
|
150 |
logging.debug("threads done")
|
|
150 | 151 |
|
151 | 152 |
|
152 | 153 |
class ClientRqHandler(SocketServer.BaseRequestHandler): |
... | ... | |
282 | 283 |
|
283 | 284 |
""" |
284 | 285 |
while True: |
285 |
print "worker %s sleeping" % worker_id
|
|
286 |
logging.debug("worker %s sleeping", worker_id)
|
|
286 | 287 |
item = incoming_queue.get(True) |
287 | 288 |
if item is None: |
288 | 289 |
break |
289 |
print "worker %s processing job %s" % (worker_id, item.data.job_id)
|
|
290 |
logging.debug("worker %s processing job %s", worker_id, item.data.job_id)
|
|
290 | 291 |
#utils.Lock('cmd') |
291 | 292 |
try: |
292 | 293 |
proc = mcpu.Processor(context, feedback=lambda x: None) |
293 | 294 |
try: |
294 | 295 |
JobRunner(proc, item, context) |
295 | 296 |
except errors.GenericError, err: |
296 |
msg = "ganeti exception %s" % err |
|
297 |
msg = "ganeti exception" |
|
298 |
logging.error(msg, exc_info=err) |
|
297 | 299 |
item.SetStatus(opcodes.Job.STATUS_FAIL, result=[msg]) |
298 |
print msg |
|
299 | 300 |
except Exception, err: |
300 |
msg = "unhandled exception %s" % err |
|
301 |
msg = "unhandled exception" |
|
302 |
logging.error(msg, exc_info=err) |
|
301 | 303 |
item.SetStatus(opcodes.Job.STATUS_FAIL, result=[msg]) |
302 |
print msg |
|
303 | 304 |
except: |
304 | 305 |
msg = "unhandled unknown exception" |
306 |
logging.error(msg, exc_info=True) |
|
305 | 307 |
item.SetStatus(opcodes.Job.STATUS_FAIL, result=[msg]) |
306 |
print msg |
|
307 | 308 |
|
308 | 309 |
finally: |
309 | 310 |
#utils.Unlock('cmd') |
310 | 311 |
#utils.LockCleanup() |
311 | 312 |
pass |
312 |
print "worker %s finish job %s" % (worker_id, item.data.job_id)
|
|
313 |
print "worker %s exiting" % worker_id
|
|
313 |
logging.debug("worker %s finish job %s", worker_id, item.data.job_id)
|
|
314 |
logging.debug("worker %s exiting", worker_id)
|
|
314 | 315 |
|
315 | 316 |
|
316 | 317 |
class GanetiContext(object): |
... | ... | |
403 | 404 |
utils.debug = options.debug |
404 | 405 |
utils.no_fork = True |
405 | 406 |
|
407 |
logger.SetupLogging(program="ganeti-masterd", debug=options.debug) |
|
408 |
|
|
406 | 409 |
CheckMaster(options.debug) |
407 | 410 |
|
408 | 411 |
master = IOServer(constants.MASTER_SOCKET, ClientRqHandler, GanetiContext()) |
Also available in: Unified diff