Recreating disks conflicts with other disk operations, therefore the
node resource lock must be acquired.
---
 lib/cmdlib.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 8c302ec..cae1940 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6443,19 +6443,19 @@ class LUInstanceRecreateDisks(LogicalUnit):
 
   def ExpandNames(self):
     self._ExpandAndLockInstance()
-    self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_APPEND
+    self.recalculate_locks[locking.LEVEL_NODE_RES] = constants.LOCKS_APPEND
     if self.op.nodes:
       self.op.nodes = [_ExpandNodeName(self.cfg, n) for n in self.op.nodes]
-      self.needed_locks[locking.LEVEL_NODE] = list(self.op.nodes)
+      self.needed_locks[locking.LEVEL_NODE_RES] = list(self.op.nodes)
     else:
-      self.needed_locks[locking.LEVEL_NODE] = []
+      self.needed_locks[locking.LEVEL_NODE_RES] = []
 
   def DeclareLocks(self, level):
-    if level == locking.LEVEL_NODE:
+    if level == locking.LEVEL_NODE_RES:
       # if we replace the nodes, we only need to lock the old primary,
       # otherwise we need to lock all nodes for disk re-creation
       primary_only = bool(self.op.nodes)
-      self._LockInstancesNodes(primary_only=primary_only)
+      self._LockInstancesNodes(primary_only=primary_only, level=level)
 
   def BuildHooksEnv(self):
     """Build hooks env.
@@ -6502,7 +6502,7 @@ class LUInstanceRecreateDisks(LogicalUnit):
                                  self.op.instance_name, errors.ECODE_INVAL)
     # if we replace nodes *and* the old primary is offline, we don't
     # check
-    assert instance.primary_node in self.needed_locks[locking.LEVEL_NODE]
+    assert instance.primary_node in self.needed_locks[locking.LEVEL_NODE_RES]
     old_pnode = self.cfg.GetNodeInfo(instance.primary_node)
     if not (self.op.nodes and old_pnode.offline):
       _CheckInstanceDown(self, instance, "cannot recreate disks")
-- 
1.7.6

Reply via email to