From: Jan Fajerski Date: Tue, 30 Jul 2019 15:32:06 +0000 (+0200) Subject: ceph-volume: fall back to PARTTYPE if PARTLABEL is empty X-Git-Tag: v15.1.0~1976^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=82d2ae7ffdf62ca93c7848fb62e506db4cda893c;p=ceph-ci.git ceph-volume: fall back to PARTTYPE if PARTLABEL is empty 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 --- diff --git a/src/ceph-volume/ceph_volume/util/device.py b/src/ceph-volume/ceph_volume/util/device.py index f06cb41ee4e..ddec0e84804 100644 --- a/src/ceph-volume/ceph_volume/util/device.py +++ b/src/ceph-volume/ceph_volume/util/device.py @@ -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] diff --git a/src/ceph-volume/ceph_volume/util/disk.py b/src/ceph-volume/ceph_volume/util/disk.py index 98239be3a44..97799466434 100644 --- a/src/ceph-volume/ceph_volume/util/disk.py +++ b/src/ceph-volume/ceph_volume/util/disk.py @@ -51,6 +51,7 @@ def _blkid_parser(output): 'TYPE': 'TYPE', 'PART_ENTRY_NAME': 'PARTLABEL', 'PART_ENTRY_UUID': 'PARTUUID', + 'PART_ENTRY_TYPE': 'PARTTYPE', 'PTTYPE': 'PTTYPE', }