From ed84f34562da21a53b6d45611a5bcf9e3edd1e84 Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Wed, 6 Feb 2019 16:11:28 +0100 Subject: [PATCH] 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 --- cinder/volume/drivers/rbd.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index ba10a99fde5..0b0baccb33d 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -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