From 583e3f6f78548b8d1aaed3cc0bb95370f5197759 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 6 Nov 2007 17:00:24 +0000 Subject: [PATCH] Make DRBD8 disks show 'degraded' status if diskless This patch enables the bdev.DRBD8 class report a degraded status if the local disk is missing. This allows `gnt-instance info` to report the actual situation in this case. Note that DRBD7 should also behave like this, however the diskless case is less often met there and we also don't want to change behaviour. The patch also fixes some docstrings for the GetSyncStatus methods. Reviewed-by: imsnah --- lib/bdev.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/bdev.py b/lib/bdev.py index 8dfa18e2c..8a80a4c1c 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -866,7 +866,7 @@ class MDRaid1(BlockDev): """Returns the sync status of the device. Returns: - (sync_percent, estimated_time) + (sync_percent, estimated_time, is_degraded) If sync_percent is None, it means all is ok If estimated_time is None, it means we can't esimate @@ -1444,7 +1444,7 @@ class DRBDev(BaseDRBD): """Returns the sync status of the device. Returns: - (sync_percent, estimated_time) + (sync_percent, estimated_time, is_degraded) If sync_percent is None, it means all is ok If estimated_time is None, it means we can't esimate @@ -1911,7 +1911,7 @@ class DRBD8(BaseDRBD): """Returns the sync status of the device. Returns: - (sync_percent, estimated_time) + (sync_percent, estimated_time, is_degraded) If sync_percent is None, it means all is ok If estimated_time is None, it means we can't esimate @@ -1936,12 +1936,14 @@ class DRBD8(BaseDRBD): else: sync_percent = None est_time = None - match = re.match("^ *[0-9]+: cs:([^ ]+).*$", line) + match = re.match("^ *\d+: cs:(\w+).*ds:(\w+)/(\w+).*$", line) if not match: raise errors.BlockDeviceError("Can't find my data in /proc (minor %d)" % self.minor) client_state = match.group(1) - is_degraded = client_state != "Connected" + local_disk_state = match.group(2) + is_degraded = (client_state != "Connected" or + local_disk_state != "UpToDate") return sync_percent, est_time, is_degraded def GetStatus(self): -- GitLab