]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fall back to PARTTYPE if PARTLABEL is empty 29401/head
authorJan Fajerski <jfajerski@suse.com>
Tue, 30 Jul 2019 15:32:06 +0000 (17:32 +0200)
committerJan Fajerski <jfajerski@suse.com>
Thu, 1 Aug 2019 13:35:30 +0000 (15:35 +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>
src/ceph-volume/ceph_volume/util/device.py
src/ceph-volume/ceph_volume/util/disk.py

index f06cb41ee4e9ae9a40b018ddf83aa5c35867142a..ddec0e84804f599d703987b1169b4be3391d967c 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}"""
@@ -416,12 +417,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
 
@@ -436,4 +449,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 98239be3a445fdf7c8f02c6f8f4fb52354571faf..97799466434c5d2cdd7c1a9337655e6182b2e82f 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',
     }