Commit 42f25b0b authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Michael Hanselmann
Browse files

Further fixes concerning drbd port release

Commit 3b3b1bca does not entirely fix the bug introduced in commit

. It fixes consistency of config data in permanent storage, but
does not ensure consistency in data held in runtime memory of masterd.

The bug of duplicate ports is still triggered when LUInstanceRemove()
invokes _RemoveDisks() and this returns False (in case
call_blockdev_remove RPC fails). The drbd ports get returned in the
pool, but execution is aborted and RemoveInstance() is never invoked.

Due to the fact that port handling is not done with
TemporaryReservationManager, ensure that ports are released, only if
disk related config data is deleted.

In _RemoveDisks() release ports only if all RPCs succeed.

Extend _RemoveDisks() to include ignore_failures argument passed by
_RemoveInstance() to handle the ports appropriately.
Signed-off-by: default avatarDimitris Aragiorgis <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 2522b7c4
......@@ -5733,7 +5733,7 @@ def _RemoveInstance(lu, feedback_fn, instance, ignore_failures):
""""Removing block devices for instance %s",
if not _RemoveDisks(lu, instance):
if not _RemoveDisks(lu, instance, ignore_failures=ignore_failures):
if not ignore_failures:
raise errors.OpExecError("Can't remove instance's disks")
feedback_fn("Warning: can't remove instance's disks")
......@@ -6862,7 +6862,7 @@ def _CreateDisks(lu, instance, to_skip=None, target_node=None):
_CreateBlockDev(lu, node, instance, device, f_create, info, f_create)
def _RemoveDisks(lu, instance, target_node=None):
def _RemoveDisks(lu, instance, target_node=None, ignore_failures=False):
"""Remove all disks for an instance.
This abstracts away some work from `AddInstance()` and
......@@ -6883,6 +6883,7 @@ def _RemoveDisks(lu, instance, target_node=None):"Removing block devices for instance %s",
all_result = True
ports_to_release = set()
for device in instance.disks:
if target_node:
edata = [(target_node, device)]
......@@ -6898,8 +6899,11 @@ def _RemoveDisks(lu, instance, target_node=None):
# if this is a DRBD disk, return its port to the pool
if device.dev_type in constants.LDS_DRBD:
tcp_port = device.logical_id[2]
if all_result or ignore_failures:
for port in ports_to_release:
if instance.disk_template == constants.DT_FILE:
file_storage_dir = os.path.dirname(instance.disks[0].logical_id[1])
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