NoHooksLU opcodes don't provide node lists on which the hooks should be executed. Execute global hooks just on master node for such opcodes.
Signed-off-by: Oleg Ponomarev <[email protected]> --- lib/mcpu.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/mcpu.py b/lib/mcpu.py index e0f3a6d..c580615 100644 --- a/lib/mcpu.py +++ b/lib/mcpu.py @@ -54,6 +54,7 @@ from ganeti import locking from ganeti import utils from ganeti import compat from ganeti import wconfd +from ganeti.cmdlib.base import NoHooksLU sighupReceived = [False] @@ -309,6 +310,7 @@ class Processor(object): self._enable_locks = enable_locks self.wconfd = wconfd # Indirection to allow testing self._wconfdcontext = context.GetWConfdContext(ec_id) + self._current_lu_no_hooks = None def _CheckLocksEnabled(self): """Checks if locking is enabled. @@ -481,11 +483,15 @@ class Processor(object): """ write_count = self.cfg.write_count + master_name = lu.cfg.GetMasterNodeName() lu.cfg.OutDate() lu.CheckPrereq() self._hm = self.BuildHooksManager(lu) - self._hm.RunPhase(constants.HOOKS_PHASE_PRE, None, True) + + node_names = [master_name] if self.current_lu_no_hooks else None + self._hm.RunPhase(constants.HOOKS_PHASE_PRE, node_names, True) + h_results = self._hm.RunPhase(constants.HOOKS_PHASE_PRE) lu.HooksCallBack(constants.HOOKS_PHASE_PRE, h_results, self.Log, None) @@ -681,6 +687,8 @@ class Processor(object): if lu_class is None: raise errors.OpCodeUnknown("Unknown opcode") + self.current_lu_no_hooks = issubclass(lu_class, NoHooksLU) + if timeout is None: calc_timeout = lambda: None else: @@ -720,7 +728,9 @@ class Processor(object): self._CheckLUResult(op, result) if self._hm is not None: - self._hm.RunPhase(constants.HOOKS_PHASE_POST, None, True, + node_names = \ + [self.cfg.GetMasterNodeName()] if self.current_lu_no_hooks else None + self._hm.RunPhase(constants.HOOKS_PHASE_POST, node_names, True, constants.POST_HOOKS_STATUS_SUCCEEDED) except: # execute global post hooks with the failed status on any exception -- 2.6.0.rc2.230.g3dd15c0
