Commit 6a752efc authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Use node resource lock when recreating instance disks

Recreating disks conflicts with other disk operations, therefore the
node resource lock must be acquired.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent a4e588b7
......@@ -6456,6 +6456,10 @@ class LUInstanceRecreateDisks(LogicalUnit):
# otherwise we need to lock all nodes for disk re-creation
primary_only = bool(self.op.nodes)
elif level == locking.LEVEL_NODE_RES:
# Copy node locks
self.needed_locks[locking.LEVEL_NODE_RES] = \
def BuildHooksEnv(self):
"""Build hooks env.
......@@ -6502,7 +6506,8 @@ 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.owned_locks(locking.LEVEL_NODE)
assert instance.primary_node in self.owned_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")
......@@ -6526,6 +6531,9 @@ class LUInstanceRecreateDisks(LogicalUnit):
instance = self.instance
assert (self.owned_locks(locking.LEVEL_NODE) ==
to_skip = []
mods = [] # keeps track of needed logical_id changes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment