Commit 03ece5f3 authored by Iustin Pop's avatar Iustin Pop
Browse files

Enhance mirror operations for DRBD8

Currently, the mirror operations (add and remove children) test against
the instance's attributes. This patch changes the check tests to work
against the actual status of the device (i.e. live data) which is more
realistic.

The changes are:
  - allow add children if the device doesn't have local storage (even if
    we believe it has)
  - early return from remove children if the device is already without
    local storage

Reviewed-by: imsnah
parent fc1dc9d7
...@@ -1850,10 +1850,10 @@ class DRBD8(BaseDRBD): ...@@ -1850,10 +1850,10 @@ class DRBD8(BaseDRBD):
""" """
if self.minor is None: if self.minor is None:
raise errors.BlockDeviceError("Can't attach to dbrd8 during AddChildren") raise errors.BlockDeviceError("Can't attach to dbrd8 during AddChildren")
if len(devices) != 2: if len(devices) != 2:
raise errors.BlockDeviceError("Need two devices for AddChildren") raise errors.BlockDeviceError("Need two devices for AddChildren")
if self._children: info = self._GetDevInfo(self.minor)
if "local_dev" in info:
raise errors.BlockDeviceError("DRBD8 already attached to a local disk") raise errors.BlockDeviceError("DRBD8 already attached to a local disk")
backend, meta = devices backend, meta = devices
if backend.dev_path is None or meta.dev_path is None: if backend.dev_path is None or meta.dev_path is None:
...@@ -1877,6 +1877,10 @@ class DRBD8(BaseDRBD): ...@@ -1877,6 +1877,10 @@ class DRBD8(BaseDRBD):
if self.minor is None: if self.minor is None:
raise errors.BlockDeviceError("Can't attach to drbd8 during" raise errors.BlockDeviceError("Can't attach to drbd8 during"
" RemoveChildren") " RemoveChildren")
# early return if we don't actually have backing storage
info = self._GetDevInfo(self.minor)
if "local_dev" not in info:
return
if len(self._children) != 2: if len(self._children) != 2:
raise errors.BlockDeviceError("We don't have two children: %s" % raise errors.BlockDeviceError("We don't have two children: %s" %
self._children) self._children)
......
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