]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fall back to PARTTYPE if PARTLABEL is empty 29462/head
authorJan Fajerski <jfajerski@suse.com>
Tue, 30 Jul 2019 15:32:06 +0000 (17:32 +0200)
committerJan Fajerski <jfajerski@suse.com>
Fri, 2 Aug 2019 09:31:59 +0000 (11:31 +0200)
In some cases ceph-disk does not populate PARTLABEL for wal and db
partitions. This commit adds the assumption that the empty string is a
valid label and falls back to identifying those disks by PARTTYPE.

Fixes: https://tracker.ceph.com/issues/40917
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
(cherry picked from commit 82d2ae7ffdf62ca93c7848fb62e506db4cda893c)

src/ceph-volume/ceph_volume/util/device.py
src/ceph-volume/ceph_volume/util/disk.py

index 29a01effa444711bf32f1dfda3abc0b9205dae04..50b74ca0f148f726bd320a5e61a14916c1830f2f 100644 (file)
@@ -5,6 +5,7 @@ from functools import total_ordering
 from ceph_volume import sys_info
 from ceph_volume.api import lvm
 from ceph_volume.util import disk
+from ceph_volume.util.constants import ceph_disk_guids
 
 report_template = """
 {dev:<25} {size:<12} {rot!s:<7} {available!s:<9} {model}"""
@@ -401,12 +402,24 @@ class CephDiskDevice(object):
             return lsblk_partlabel
         return self.device.blkid_api.get('PARTLABEL', '')
 
+    @property
+    def parttype(self):
+        """
+        Seems like older version do not detect PARTTYPE correctly (assuming the
+        info in util/disk.py#lsblk is still valid).
+        SImply resolve to using blkid since lsblk will throw an error if asked
+        for an unknown columns
+        """
+        return self.device.blkid_api.get('PARTTYPE', '')
+
     @property
     def is_member(self):
         if self._is_ceph_disk_member is None:
             if 'ceph' in self.partlabel:
                 self._is_ceph_disk_member = True
                 return True
+            elif self.parttype in ceph_disk_guids.keys():
+                return True
             return False
         return self._is_ceph_disk_member
 
@@ -421,4 +434,5 @@ class CephDiskDevice(object):
         for t in types:
             if t in self.partlabel:
                 return t
-        return 'unknown'
+        label = ceph_disk_guids.get(self.parttype, {})
+        return label.get('type', 'unknown').split('.')[-1]
index da6411329a1682806fb62c8aca79ae63264bb933..49ccdb899d2c61580bbacbcadf3a40ce5c7143dc 100644 (file)
@@ -51,6 +51,7 @@ def _blkid_parser(output):
         'TYPE': 'TYPE',
         'PART_ENTRY_NAME': 'PARTLABEL',
         'PART_ENTRY_UUID': 'PARTUUID',
+        'PART_ENTRY_TYPE': 'PARTTYPE',
         'PTTYPE': 'PTTYPE',
     }