Add correct locking of master node to gnt-debug delay
authorHrvoje Ribicic <riba@google.com>
Thu, 16 Jan 2014 12:08:18 +0000 (12:08 +0000)
committerHrvoje Ribicic <riba@google.com>
Mon, 20 Jan 2014 12:11:53 +0000 (13:11 +0100)
The gnt-debug delay command required locks for all nodes except the
master - this patch fixes the issue by adding master to the locks
whenever needed.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/cmdlib/test.py

index 52787c3..485a83d 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -53,12 +53,20 @@ class LUTestDelay(NoHooksLU):
 
     """
     self.needed_locks = {}
+
+    if self.op.on_nodes or self.op.on_master:
+      self.needed_locks[locking.LEVEL_NODE] = []
+
     if self.op.on_nodes:
       # _GetWantedNodes can be used here, but is not always appropriate to use
       # this way in ExpandNames. Check LogicalUnit.ExpandNames docstring for
       # more information.
       self.op.on_nodes = GetWantedNodes(self, self.op.on_nodes)
-      self.needed_locks[locking.LEVEL_NODE] = self.op.on_nodes
+      self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_nodes)
+
+    if self.op.on_master:
+      # The node lock should be acquired for the master as well.
+      self.needed_locks[locking.LEVEL_NODE].append(self.cfg.GetMasterNode())
 
   def _TestDelay(self):
     """Do the actual sleep.