Commit 3de8301d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Merge branch 'devel-2.4'

* devel-2.4:
  TLReplaceDisks: Use implicit loop for dictionary
  Release unneeded locks while replacing disks
  locking: Export “list_owned” from lock manager
  gnt-instance: Fix typo in error message
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parents 580c971e 29b8eaee
......@@ -717,7 +717,7 @@ def ReplaceDisks(opts, args):
cnt = [opts.on_primary, opts.on_secondary,,
new_2ndary is not None, iallocator is not None].count(True)
if cnt != 1:
raise errors.OpPrereqError("One and only one of the -p, -s, -a, -n and -i"
raise errors.OpPrereqError("One and only one of the -p, -s, -a, -n and -I"
" options must be passed", errors.ECODE_INVAL)
elif opts.on_primary:
mode = constants.REPLACE_DISK_PRI
......@@ -8770,18 +8770,24 @@ class TLReplaceDisks(Tasklet):
for node in check_nodes:
_CheckNodeOnline(, node)
touched_nodes = frozenset([self.new_node, self.other_node,
if[locking.LEVEL_NODE] == locking.ALL_SET:
# Release unneeded node locks
for name in[locking.LEVEL_NODE]:
if name not in touched_nodes:
# Check whether disks are valid
for disk_idx in self.disks:
# Get secondary node IP addresses
node_2nd_ip = {}
for node_name in [self.target_node, self.other_node, self.new_node]:
if node_name is not None:
node_2nd_ip[node_name] = self.cfg.GetNodeInfo(node_name).secondary_ip
self.node_secondary_ip = node_2nd_ip
self.node_secondary_ip = \
dict((node_name, self.cfg.GetNodeInfo(node_name).secondary_ip)
for node_name in touched_nodes
if node_name is not None)
def Exec(self, feedback_fn):
"""Execute disk replacement.
......@@ -8792,6 +8798,13 @@ class TLReplaceDisks(Tasklet):
if self.delay_iallocator:
if ([locking.LEVEL_NODE] == locking.ALL_SET and
# Verify owned locks before starting operation
owned_locks =
assert set(owned_locks) == set(self.node_secondary_ip), \
"Not owning the correct locks: %s" % (owned_locks, )
if not self.disks:
feedback_fn("No disks need replacement")
......@@ -8820,6 +8833,15 @@ class TLReplaceDisks(Tasklet):
if activate_disks:
_SafeShutdownInstanceDisks(, self.instance)
if __debug__:
# Verify owned locks
owned_locks =
assert ((self.early_release and not owned_locks) or
(not self.early_release and
set(owned_locks) == set(self.node_secondary_ip))), \
("Not owning the correct locks, early_release=%s, owned=%r" %
(self.early_release, owned_locks))
def _CheckVolumeGroup(self, nodes):"Checking volume groups")
......@@ -1384,6 +1384,8 @@ class GanetiLockManager:
return self.__keyring[level]._list_owned()
list_owned = _list_owned
def _upper_owned(self, level):
"""Check that we don't own any lock at a level greater than the given one.
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