Revision 7c4bd156
b/lib/server/masterd.py | ||
---|---|---|
59 | 59 |
from ganeti import query |
60 | 60 |
from ganeti import runtime |
61 | 61 |
from ganeti import pathutils |
62 |
from ganeti import ht |
|
62 | 63 |
|
63 | 64 |
|
64 | 65 |
CLIENT_REQUEST_WORKERS = 16 |
... | ... | |
442 | 443 |
elif method == luxi.REQ_SET_WATCHER_PAUSE: |
443 | 444 |
(until, ) = args |
444 | 445 |
|
445 |
if until is None: |
|
446 |
logging.info("Received request to no longer pause the watcher") |
|
447 |
else: |
|
448 |
if not isinstance(until, (int, float)): |
|
449 |
raise TypeError("Duration must be an integer or float") |
|
450 |
|
|
451 |
if until < time.time(): |
|
452 |
raise errors.GenericError("Unable to set pause end time in the past") |
|
453 |
|
|
454 |
logging.info("Received request to pause the watcher until %s", until) |
|
455 |
|
|
456 |
return _SetWatcherPause(until) |
|
446 |
return _SetWatcherPause(context, until) |
|
457 | 447 |
|
458 | 448 |
else: |
459 | 449 |
logging.info("Received invalid request '%s'", method) |
... | ... | |
554 | 544 |
self.glm.remove(locking.LEVEL_NODE_RES, name) |
555 | 545 |
|
556 | 546 |
|
557 |
def _SetWatcherPause(until): |
|
547 |
def _SetWatcherPause(context, until):
|
|
558 | 548 |
"""Creates or removes the watcher pause file. |
559 | 549 |
|
550 |
@type context: L{GanetiContext} |
|
551 |
@param context: Global Ganeti context |
|
560 | 552 |
@type until: None or int |
561 | 553 |
@param until: Unix timestamp saying until when the watcher shouldn't run |
562 | 554 |
|
563 | 555 |
""" |
556 |
node_names = context.cfg.GetNodeList() |
|
557 |
|
|
564 | 558 |
if until is None: |
565 |
utils.RemoveFile(pathutils.WATCHER_PAUSEFILE)
|
|
559 |
logging.info("Received request to no longer pause watcher")
|
|
566 | 560 |
else: |
567 |
utils.WriteFile(pathutils.WATCHER_PAUSEFILE, |
|
568 |
data="%d\n" % (until, )) |
|
561 |
if not ht.TNumber(until): |
|
562 |
raise TypeError("Duration must be numeric") |
|
563 |
|
|
564 |
if until < time.time(): |
|
565 |
raise errors.GenericError("Unable to set pause end time in the past") |
|
566 |
|
|
567 |
logging.info("Received request to pause watcher until %s", until) |
|
568 |
|
|
569 |
result = context.rpc.call_set_watcher_pause(node_names, until) |
|
570 |
|
|
571 |
errmsg = utils.CommaJoin("%s (%s)" % (node_name, nres.fail_msg) |
|
572 |
for (node_name, nres) in result.items() |
|
573 |
if nres.fail_msg and not nres.offline) |
|
574 |
if errmsg: |
|
575 |
raise errors.OpExecError("Watcher pause was set where possible, but failed" |
|
576 |
" on the following node(s): %s" % errmsg) |
|
569 | 577 |
|
570 | 578 |
return until |
571 | 579 |
|
Also available in: Unified diff