Check DRBD status in cluster verify
authorThomas Thrainer <thomasth@google.com>
Tue, 18 Jun 2013 14:34:18 +0000 (16:34 +0200)
committerThomas Thrainer <thomasth@google.com>
Thu, 20 Jun 2013 07:34:56 +0000 (09:34 +0200)
If the status of DRBD disks is degraded or in a faulty state, issue an
error in cluster verify.

Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/cmdlib/cluster.py
lib/constants.py

index 9ac14ae..836d6dd 100644 (file)
@@ -1874,11 +1874,18 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
                     constants.CV_EINSTANCEFAULTYDISK, instance,
                     "couldn't retrieve status for disk/%s on %s: %s",
                     idx, self.cfg.GetNodeName(nname), bdev_status)
-      self._ErrorIf((inst_config.disks_active and
-                     success and
-                     bdev_status.ldisk_status == constants.LDS_FAULTY),
-                    constants.CV_EINSTANCEFAULTYDISK, instance,
-                    "disk/%s on %s is faulty", idx, self.cfg.GetNodeName(nname))
+
+      if inst_config.disks_active and success and \
+         (bdev_status.is_degraded or
+          bdev_status.ldisk_status != constants.LDS_OKAY):
+        msg = "disk/%s on %s" % (idx, self.cfg.GetNodeName(nname))
+        if bdev_status.is_degraded:
+          msg += " is degraded"
+        if bdev_status.ldisk_status != constants.LDS_OKAY:
+          msg += "; state is '%s'" % \
+                 constants.LDS_NAMES[bdev_status.ldisk_status]
+
+        self._Error(constants.CV_EINSTANCEFAULTYDISK, instance, msg)
 
     self._ErrorIf(pnode_img.rpc_fail and not pnode_img.offline,
                   constants.CV_ENODERPC, pnode, "instance %s, connection to"
index ac25882..926f5a7 100644 (file)
@@ -428,6 +428,12 @@ VALID_STORAGE_OPERATIONS = {
  LDS_UNKNOWN,
  LDS_FAULTY) = range(1, 4)
 
+LDS_NAMES = {
+  LDS_OKAY: "ok",
+  LDS_UNKNOWN: "unknown",
+  LDS_FAULTY: "faulty",
+}
+
 # disk template types
 DT_BLOCK = "blockdev"
 DT_DISKLESS = "diskless"