]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix blkid on inaccessible devices 54453/head
authorSascha Lucas <sascha_lucas@web.de>
Fri, 10 Nov 2023 17:40:57 +0000 (18:40 +0100)
committerSascha Lucas <sascha_lucas@web.de>
Sat, 11 Nov 2023 10:40:37 +0000 (11:40 +0100)
There exists block devices which can not be accessed. For example DRBD
/dev/drbdX in secondary state. `blkid` can not read from this:

  $ blkid -c /dev/null -p /dev/drbd4
  blkid: error: /dev/drbd4: Wrong medium type

Since release 17.2.7 this results in "CEPHADM_REFRESH_FAILED: failed to
probe daemons or devices"[1] and the following trace:

  File "/usr/lib/python3.6/site-packages/ceph_volume/util/device.py", line 482, in is_partition
    return self.blkid_api['TYPE'] == 'part'

Fix this by using `get()` method, so that it defaults to `None` if the
key does not exist. And while at it also switch to `get()` in an other
reference to this key.

Probably caused by commit 2422ad867dff9d526d7e8be543178c897991097f ???

[1] https://lists.ceph.io/hyperkitty/list/ceph-users@ceph.io/thread/ZSD4OPDMCEXOW74IJH4L4D5PQXFFINGS/

Signed-off-by: Sascha Lucas <sascha_lucas@web.de>
src/ceph-volume/ceph_volume/util/device.py

index bb806292f2c48aab02cfbf9f770187cc17af97ba..a9acb7f20437f3f85bf77ffaeeb6d813c4fc97f1 100644 (file)
@@ -464,7 +464,7 @@ class Device(object):
         elif self.disk_api:
             return self.disk_api['TYPE']
         elif self.blkid_api:
-            return self.blkid_api['TYPE']
+            return self.blkid_api.get('TYPE')
 
     @property
     def is_mpath(self):
@@ -480,7 +480,7 @@ class Device(object):
         if self.disk_api:
             return self.disk_api['TYPE'] == 'part'
         elif self.blkid_api:
-            return self.blkid_api['TYPE'] == 'part'
+            return self.blkid_api.get('TYPE') == 'part'
         return False
 
     @property