Merge "Fix python3 compatibility of rbd get_fsid" into stable/rocky

This commit is contained in:
Zuul 2020-03-05 15:52:04 +00:00 committed by Gerrit Code Review
commit 7cad6da6f1
1 changed files with 13 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import logging
import math import math
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import encodeutils
from oslo_utils import units from oslo_utils import units
from six.moves import urllib from six.moves import urllib
@ -469,7 +470,18 @@ class Store(driver.Store):
rados_id=self.user) as conn: rados_id=self.user) as conn:
fsid = None fsid = None
if hasattr(conn, 'get_fsid'): if hasattr(conn, 'get_fsid'):
fsid = conn.get_fsid() # Librados's get_fsid is represented as binary
# in py3 instead of str as it is in py2.
# This is causing problems with ceph.
# Decode binary to str fixes these issues.
# Fix with encodeutils.safe_decode CAN BE REMOVED
# after librados's fix will be stable.
#
# More informations:
# https://bugs.launchpad.net/glance-store/+bug/1816721
# https://bugs.launchpad.net/cinder/+bug/1816468
# https://tracker.ceph.com/issues/38381
fsid = encodeutils.safe_decode(conn.get_fsid())
with conn.open_ioctx(self.pool) as ioctx: with conn.open_ioctx(self.pool) as ioctx:
order = int(math.log(self.WRITE_CHUNKSIZE, 2)) order = int(math.log(self.WRITE_CHUNKSIZE, 2))
LOG.debug('creating image %s with order %d and size %d', LOG.debug('creating image %s with order %d and size %d',