]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: compatibility fix for python 3 24008/head
authorTim Serong <tserong@suse.com>
Mon, 10 Sep 2018 10:27:11 +0000 (20:27 +1000)
committerTim Serong <tserong@suse.com>
Wed, 12 Sep 2018 06:45:26 +0000 (16:45 +1000)
In python 3, dev is a string, but mounts_dev is bytes (because
/proc/mounts was opened with mode 'rb') so they can't compare
equal, resulting in is_mounted() returning None for mounted OSDs.
The safest fix for this we could come up with was to normalize
dev to a str using _bytes2str() (just in case), and open
/proc/mounts in mode 'r', so its lines are interpreted as strs.

Fixes: https://tracker.ceph.com/issues/35906
Signed-off-by: Tim Serong <tserong@suse.com>
src/ceph-disk/ceph_disk/main.py

index 8f32ce4d514598d29274da18fb89531b6d1b19d9..639c49e7e10ec361228f9f3918e28273bcd08515 100644 (file)
@@ -909,8 +909,8 @@ def is_mounted(dev):
     """
     Check if the given device is mounted.
     """
-    dev = os.path.realpath(dev)
-    with open(PROCDIR + '/mounts', 'rb') as proc_mounts:
+    dev = os.path.realpath(_bytes2str(dev))
+    with open(PROCDIR + '/mounts', 'r') as proc_mounts:
         for line in proc_mounts:
             fields = line.split()
             if len(fields) < 3: