Run post phase of node-remove on the removed node as well.

Signed-off-by: Luca Bigliardi <[email protected]>
---
 doc/hooks.rst |    2 +-
 lib/cmdlib.py |    7 ++++++-
 lib/mcpu.py   |    1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/doc/hooks.rst b/doc/hooks.rst
index ecd6c9e..bb66158 100644
--- a/doc/hooks.rst
+++ b/doc/hooks.rst
@@ -133,7 +133,7 @@ Removes a node from the cluster.
 :directory: node-remove
 :env. vars: NODE_NAME
 :pre-execution: all existing nodes except the removed node
-:post-execution: all existing nodes except the removed node
+:post-execution: all existing nodes
 
 OP_NODE_SET_PARAMS
 ++++++++++++++++++
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 02a5128..82bf23b 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2155,7 +2155,8 @@ class LURemoveNode(LogicalUnit):
       "NODE_NAME": self.op.node_name,
       }
     all_nodes = self.cfg.GetNodeList()
-    all_nodes.remove(self.op.node_name)
+    if self.op.node_name in all_nodes:
+      all_nodes.remove(self.op.node_name)
     return env, all_nodes, all_nodes
 
   def CheckPrereq(self):
@@ -2198,6 +2199,10 @@ class LURemoveNode(LogicalUnit):
 
     self.context.RemoveNode(node.name)
 
+    # Run hooks on the node before it's removed
+    hm = self.proc.hmclass(self.rpc.call_hooks_runner, self)
+    hm.RunPhase(constants.HOOKS_PHASE_POST, [node.name])
+
     result = self.rpc.call_node_leave_cluster(node.name)
     msg = result.fail_msg
     if msg:
diff --git a/lib/mcpu.py b/lib/mcpu.py
index 589b369..bee7218 100644
--- a/lib/mcpu.py
+++ b/lib/mcpu.py
@@ -111,6 +111,7 @@ class Processor(object):
     self._feedback_fn = None
     self.exclusive_BGL = False
     self.rpc = rpc.RpcRunner(context.cfg)
+    self.hmclass = HooksMaster
 
   def _ExecLU(self, lu):
     """Logical Unit execution sequence.
-- 
1.5.4.3

Reply via email to