From abd8e8368ada89922620e7092347a3f8678db68e Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 11 Feb 2010 16:06:24 +0100
Subject: [PATCH] Run instance hooks on more nodes

This should fix issue 68: some hooks should be run on more nodes than
currently. GrowDisk runs on both nodes, remove run the post hook on the
instance's nodes, and failover and migrate run the post hook on the
source node too.

Thanks to Maxence for the initial investigation and patch.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 doc/hooks.rst | 10 +++++-----
 lib/cmdlib.py | 16 +++++++++-------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/doc/hooks.rst b/doc/hooks.rst
index 9f32d735d..2effa481c 100644
--- a/doc/hooks.rst
+++ b/doc/hooks.rst
@@ -262,7 +262,7 @@ and secondary before failover.
 :directory: instance-failover
 :env. vars: IGNORE_CONSISTENCY, OLD_SECONDARY, OLD_PRIMARY, NEW_SECONDARY, NEW_PRIMARY
 :pre-execution: master node, secondary node
-:post-execution: master node, secondary node
+:post-execution: master node, primary and secondary nodes
 
 OP_INSTANCE_MIGRATE
 ++++++++++++++++++++
@@ -274,7 +274,7 @@ and secondary before migration.
 :directory: instance-migrate
 :env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP, OLD_SECONDARY, OLD_PRIMARY, NEW_SECONDARY, NEW_PRIMARY
 :pre-execution: master node, secondary node
-:post-execution: master node, secondary node
+:post-execution: master node, primary and secondary nodes
 
 
 OP_INSTANCE_REMOVE
@@ -285,7 +285,7 @@ Remove an instance.
 :directory: instance-remove
 :env. vars: only the standard instance vars
 :pre-execution: master node
-:post-execution: master node
+:post-execution: master node, primary and secondary nodes
 
 OP_INSTANCE_REPLACE_DISKS
 +++++++++++++++++++++++++
@@ -304,8 +304,8 @@ Grows the disk of an instance.
 
 :directory: disk-grow
 :env. vars: DISK, AMOUNT
-:pre-execution: master node, primary node
-:post-execution: master node, primary node
+:pre-execution: master node, primary and secondary nodes
+:post-execution: master node, primary and secondary nodes
 
 OP_INSTANCE_RENAME
 ++++++++++++++++++
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 473c70560..6a4e0dfaf 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -4228,7 +4228,8 @@ class LURemoveInstance(LogicalUnit):
     env = _BuildInstanceHookEnvByObject(self, self.instance)
     env["SHUTDOWN_TIMEOUT"] = self.shutdown_timeout
     nl = [self.cfg.GetMasterNode()]
-    return env, nl, nl
+    nl_post = list(self.instance.all_nodes) + nl
+    return env, nl, nl_post
 
   def CheckPrereq(self):
     """Check prerequisites.
@@ -4600,7 +4601,9 @@ class LUFailoverInstance(LogicalUnit):
       }
     env.update(_BuildInstanceHookEnvByObject(self, instance))
     nl = [self.cfg.GetMasterNode()] + list(instance.secondary_nodes)
-    return env, nl, nl
+    nl_post = list(nl)
+    nl_post.append(source_node)
+    return env, nl, nl_post
 
   def CheckPrereq(self):
     """Check prerequisites.
@@ -4754,7 +4757,9 @@ class LUMigrateInstance(LogicalUnit):
         "NEW_SECONDARY": source_node,
         })
     nl = [self.cfg.GetMasterNode()] + list(instance.secondary_nodes)
-    return env, nl, nl
+    nl_post = list(nl)
+    nl_post.append(source_node)
+    return env, nl, nl_post
 
 
 class LUMoveInstance(LogicalUnit):
@@ -7272,10 +7277,7 @@ class LUGrowDisk(LogicalUnit):
       "AMOUNT": self.op.amount,
       }
     env.update(_BuildInstanceHookEnvByObject(self, self.instance))
-    nl = [
-      self.cfg.GetMasterNode(),
-      self.instance.primary_node,
-      ]
+    nl = [self.cfg.GetMasterNode()] + list(self.instance.all_nodes)
     return env, nl, nl
 
   def CheckPrereq(self):
-- 
GitLab