]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: mark a device not available if it belongs to ceph-disk 26117/head
authorAndrew Schoen <aschoen@redhat.com>
Tue, 22 Jan 2019 15:32:00 +0000 (09:32 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 24 Jan 2019 15:51:01 +0000 (09:51 -0600)
The `ceph-volume inventory` command will now show if a device is being
used by ceph-disk and mark it not available if so.

Fixes: https://tracker.ceph.com/issues/24871
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
(cherry picked from commit d14a6b284c44a3f61c0dd8c60ccc474203003653)

src/ceph-volume/ceph_volume/tests/util/test_device.py
src/ceph-volume/ceph_volume/util/device.py

index ca90453892fe2338262ae6f49872a9a8d6e78968..8be5f8e4be3dd0c897ea84259ff4ac0e5bf54fab 100644 (file)
@@ -92,6 +92,14 @@ class TestDevice(object):
         disk = device.Device("/dev/sda")
         assert disk.is_ceph_disk_member
 
+    def test_is_ceph_disk_member_not_available(self, device_info):
+        lsblk = {"PARTLABEL": "ceph data"}
+        device_info(lsblk=lsblk)
+        disk = device.Device("/dev/sda")
+        assert disk.is_ceph_disk_member
+        assert not disk.available
+        assert "Used by ceph-disk" in disk.rejected_reasons
+
     def test_is_not_ceph_disk_member_lsblk(self, device_info):
         lsblk = {"PARTLABEL": "gluster partition"}
         device_info(lsblk=lsblk)
index fb7a411985dafa1cb3783ad9f5b9f1000a9f14ed..06f90cd374417a7fef172e9d1a185b2f19a9d235 100644 (file)
@@ -209,9 +209,6 @@ class Device(object):
         dev_id.replace(' ', '_')
         return dev_id
 
-
-
-
     def _set_lvm_membership(self):
         if self._is_lvm_member is None:
             # this is contentious, if a PV is recognized by LVM but has no
@@ -282,7 +279,14 @@ class Device(object):
 
     @property
     def is_ceph_disk_member(self):
-        return self.ceph_disk.is_member
+        is_member = self.ceph_disk.is_member
+        if self.sys_api.get("partitions"):
+            for part in self.sys_api.get("partitions").keys():
+                part = Device("/dev/%s" % part)
+                if part.is_ceph_disk_member:
+                    is_member = True
+                    break
+        return is_member
 
     @property
     def is_mapper(self):
@@ -356,6 +360,9 @@ class Device(object):
         ]
         rejected = [reason for (k, v, reason) in reasons if
                     self.sys_api.get(k, '') == v]
+        if self.is_ceph_disk_member:
+            rejected.append("Used by ceph-disk")
+
         return len(rejected) == 0, rejected