Fix python3 compatibility of rbd get_fsid

In python3 librados's get_fsid() function is represented as binary.
Because of this, conditional where fsid is compared with fsid parsed
from glance's direct url is not true, then cinder-glance
acceleration is not working. This patch is fixing this.
More informations are in closing bug.

Closes-Bug: #1816468

Change-Id: I69d0685ec845355329f771f27f8894d9e988ae35
This commit is contained in:
Michal Arbet 2019-02-06 16:11:28 +01:00
parent a714ac1ec1
commit ed84f34562
1 changed files with 17 additions and 3 deletions

View File

@ -1381,7 +1381,20 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
def _get_fsid(self):
with RADOSClient(self) as client:
return client.cluster.get_fsid()
# Librados's get_fsid is represented as binary
# in py3 instead of str as it is in py2.
# This causes problems with cinder rbd
# driver as we rely on get_fsid return value
# which should be string, not bytes.
# Decode binary to str fixes these issues.
# Fix with encodeutils.safe_decode CAN BE REMOVED
# after librados's fix will be in stable for some time.
#
# More informations:
# https://bugs.launchpad.net/glance-store/+bug/1816721
# https://bugs.launchpad.net/cinder/+bug/1816468
# https://tracker.ceph.com/issues/38381
return encodeutils.safe_decode(client.cluster.get_fsid())
def _is_cloneable(self, image_location, image_meta):
try:
@ -1746,8 +1759,9 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
with linuxrbd.RBDClient(rbd_user, rbd_pool, conffile=rbd_ceph_conf,
rbd_cluster_name=rbd_cluster_name) as target:
if ((rbd_fsid != self._get_fsid() or
rbd_fsid != target.client.get_fsid())):
if (rbd_fsid != self._get_fsid()) or \
(rbd_fsid != encodeutils.safe_decode(
target.client.get_fsid())):
LOG.info('Migration between clusters is not supported. '
'Falling back to generic migration.')
return refuse_to_migrate