From acf931b71580fb9918945414673f6bd76f3a0fee Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Mon, 13 Sep 2010 16:46:41 +0200 Subject: [PATCH] Remove mcpu's ReportLocks callback This is no longer needed with the new lock monitor. One callback is kept to check for cancelled jobs. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/jqueue.py | 6 ++--- lib/mcpu.py | 62 ++++----------------------------------------------- 2 files changed, 6 insertions(+), 62 deletions(-) diff --git a/lib/jqueue.py b/lib/jqueue.py index bd4d98625..b1e3ee034 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -467,10 +467,8 @@ class _OpExecCallbacks(mcpu.OpExecCbBase): timestamp = utils.SplitTime(time.time()) self._AppendFeedback(timestamp, log_type, log_msg) - def ReportLocks(self, msg): - """Write locking information to the job. - - Called whenever the LU processor is waiting for a lock or has acquired one. + def CheckCancel(self): + """Check whether job has been cancelled. """ assert self._op.status in (constants.OP_STATUS_WAITLOCK, diff --git a/lib/mcpu.py b/lib/mcpu.py index 4039d75da..7248f9378 100644 --- a/lib/mcpu.py +++ b/lib/mcpu.py @@ -153,8 +153,8 @@ class OpExecCbBase: # pylint: disable-msg=W0232 """ - def ReportLocks(self, msg): - """Report lock operations. + def CheckCancel(self): + """Check whether job has been cancelled. """ @@ -238,59 +238,6 @@ class Processor(object): self.rpc = rpc.RpcRunner(context.cfg) self.hmclass = HooksMaster - def _ReportLocks(self, level, names, shared, timeout, acquired, result): - """Reports lock operations. - - @type level: int - @param level: Lock level - @type names: list or string - @param names: Lock names - @type shared: bool - @param shared: Whether the locks should be acquired in shared mode - @type timeout: None or float - @param timeout: Timeout for acquiring the locks - @type acquired: bool - @param acquired: Whether the locks have already been acquired - @type result: None or set - @param result: Result from L{locking.GanetiLockManager.acquire} - - """ - parts = [] - - # Build message - if acquired: - if result is None: - parts.append("timeout") - else: - parts.append("acquired") - else: - parts.append("waiting") - if timeout is None: - parts.append("blocking") - else: - parts.append("timeout=%0.6fs" % timeout) - - parts.append(locking.LEVEL_NAMES[level]) - - if names == locking.ALL_SET: - parts.append("ALL") - elif isinstance(names, basestring): - parts.append(names) - else: - parts.append(",".join(sorted(names))) - - if shared: - parts.append("shared") - else: - parts.append("exclusive") - - msg = "/".join(parts) - - logging.debug("LU locks %s", msg) - - if self._cbs: - self._cbs.ReportLocks(msg) - def _AcquireLocks(self, level, names, shared, timeout): """Acquires locks via the Ganeti lock manager. @@ -304,13 +251,12 @@ class Processor(object): @param timeout: Timeout for acquiring the locks """ - self._ReportLocks(level, names, shared, timeout, False, None) + if self._cbs: + self._cbs.CheckCancel() acquired = self.context.glm.acquire(level, names, shared=shared, timeout=timeout) - self._ReportLocks(level, names, shared, timeout, True, acquired) - return acquired def _ExecLU(self, lu): -- GitLab