Use resource lock when setting node parameters
authorMichael Hanselmann <hansmi@google.com>
Tue, 15 Nov 2011 06:21:34 +0000 (07:21 +0100)
committerMichael Hanselmann <hansmi@google.com>
Tue, 15 Nov 2011 09:52:05 +0000 (10:52 +0100)
Also acquire instance and resource locks in shared mode (see comment).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/cmdlib.py

index af131ee..c61bc4d 100644 (file)
@@ -5309,6 +5309,16 @@ class LUNodeSetParams(LogicalUnit):
     else:
       self.needed_locks = {locking.LEVEL_NODE: self.op.node_name}
 
+    # Since modifying a node can have severe effects on currently running
+    # operations the resource lock is at least acquired in shared mode
+    self.needed_locks[locking.LEVEL_NODE_RES] = \
+      self.needed_locks[locking.LEVEL_NODE]
+
+    # Get node resource and instance locks in shared mode; they are not used
+    # for anything but read-only access
+    self.share_locks[locking.LEVEL_NODE_RES] = 1
+    self.share_locks[locking.LEVEL_INSTANCE] = 1
+
     if self.lock_instances:
       self.needed_locks[locking.LEVEL_INSTANCE] = \
         frozenset(self.cfg.GetInstancesInfoByFilter(self._InstanceFilter))