Commit 9db6dbce authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement degraded status for logical volumes

Logical volumes can be 'degraded' in a similar way to mirrored devices,
when their underlying storage has gone away (i.e. after a physical disk
failure and 'vgreduce --removemissing'). If we can detect this, we can
prevent mistaken replaces of disks that would use this LV (or its
parent) as source data.

This patch adds support for computing the degraded attribute and
modifies gnt-instance to warn if the LV is virtual.

Reviewed-by: imsnah
parent 0fbbf897
...@@ -451,6 +451,38 @@ class LogicalVolume(BlockDev): ...@@ -451,6 +451,38 @@ class LogicalVolume(BlockDev):
return retval return retval
def GetSyncStatus(self):
"""Returns the sync status of the device.
If this device is a mirroring device, this function returns the
status of the mirror.
Returns:
(sync_percent, estimated_time, is_degraded)
For logical volumes, sync_percent and estimated_time are always
None (no recovery in progress, as we don't handle the mirrored LV
case).
For the is_degraded parameter, we check if the logical volume has
the 'virtual' type, which means it's not backed by existing
storage anymore (read from it return I/O error). This happens
after a physical disk failure and subsequent 'vgreduce
--removemissing' on the volume group.
"""
result = utils.RunCmd(["lvs", "--noheadings", "-olv_attr", self.dev_path])
if result.failed:
logger.Error("Can't display lv: %s" % result.fail_reason)
return None, None, True
out = result.stdout.strip()
# format: type/permissions/alloc/fixed_minor/state/open
if len(out) != 6:
return None, None, True
is_degraded = out[0] == 'v' # virtual volume, i.e. doesn't have
# backing storage
return None, None, is_degraded
def Open(self, force=False): def Open(self, force=False):
"""Make the device ready for I/O. """Make the device ready for I/O.
......
...@@ -537,6 +537,12 @@ def _FormatBlockDevInfo(buf, dev, indent_level): ...@@ -537,6 +537,12 @@ def _FormatBlockDevInfo(buf, dev, indent_level):
else: else:
degr_text = "ok" degr_text = "ok"
buf.write(" %s, status %s" % (sync_text, degr_text)) buf.write(" %s, status %s" % (sync_text, degr_text))
elif dtype == constants.LD_LV:
if degr:
degr_text = " *DEGRADED* (failed drive?)"
else:
degr_text = ""
buf.write(degr_text)
buf.write("\n") buf.write("\n")
if dev["iv_name"] is not None: if dev["iv_name"] is not None:
......
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