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: v13.2.7~211^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F29463%2Fhead;p=ceph.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 (cherry picked from commit 82d2ae7ffdf62ca93c7848fb62e506db4cda893c) --- diff --git a/src/ceph-volume/ceph_volume/util/device.py b/src/ceph-volume/ceph_volume/util/device.py index 700852ad83d4..9e0f186090cc 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}""" @@ -411,12 +412,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 @@ -431,4 +444,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 da6411329a16..49ccdb899d2c 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', }