Make DRBD8 disks show 'degraded' status if diskless
authorIustin Pop <iustin@google.com>
Tue, 6 Nov 2007 17:00:24 +0000 (17:00 +0000)
committerIustin Pop <iustin@google.com>
Tue, 6 Nov 2007 17:00:24 +0000 (17:00 +0000)
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

index 8dfa18e..8a80a4c 100644 (file)
@@ -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):