]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: mark a device not available if it belongs to ceph-disk 26084/head
authorAndrew Schoen <aschoen@redhat.com>
Tue, 22 Jan 2019 15:32:00 +0000 (09:32 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Tue, 22 Jan 2019 22:12:34 +0000 (16:12 -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>
src/ceph-volume/ceph_volume/tests/util/test_device.py
src/ceph-volume/ceph_volume/util/device.py

index 1d44facd875bacca827e2ecb52b77fb2e745f546..7eea92ecd0c524f65aa6d9ebe70ad64ec8045d02 100644 (file)
@@ -106,6 +106,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 667bb97f2569c1481103a9ab86de7e67205f454a..cb62a744fbf2a677b3d0534e3c6911cae4344e02 100644 (file)
@@ -217,9 +217,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
@@ -300,7 +297,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):
@@ -374,6 +378,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