RBD: Pass bytes type for mon_command inbuf

Ceph Pacific enforces that bytes instead of str
are used here.

Closes-Bug: #1913449
Change-Id: Icf9f6409009250f766f619019252617fc9b3e1e7
(cherry picked from commit 11704d0e8c)
(cherry picked from commit 39ec61c296)
This commit is contained in:
Eric Harney 2021-02-02 09:23:25 -05:00
parent d34e4d12fa
commit e50570b1dd
3 changed files with 13 additions and 6 deletions

View File

@ -1583,9 +1583,9 @@ class RBDTestCase(test.TestCase):
return_value=dynamic_total):
result = self.driver._get_pool_stats()
client.cluster.mon_command.assert_has_calls([
mock.call('{"prefix":"df", "format":"json"}', ''),
mock.call('{"prefix":"df", "format":"json"}', b''),
mock.call('{"prefix":"osd pool get-quota", "pool": "rbd",'
' "format":"json"}', ''),
' "format":"json"}', b''),
])
self.assertEqual((free_capacity, total_capacity), result)
@ -1606,9 +1606,9 @@ class RBDTestCase(test.TestCase):
]
result = self.driver._get_pool_stats()
client.cluster.mon_command.assert_has_calls([
mock.call('{"prefix":"df", "format":"json"}', ''),
mock.call('{"prefix":"df", "format":"json"}', b''),
mock.call('{"prefix":"osd pool get-quota", "pool": "rbd",'
' "format":"json"}', ''),
' "format":"json"}', b''),
])
free_capacity = 1.56
total_capacity = 3.0

View File

@ -550,14 +550,14 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
with RADOSClient(self) as client:
ret, df_outbuf, __ = client.cluster.mon_command(
'{"prefix":"df", "format":"json"}', '')
'{"prefix":"df", "format":"json"}', b'')
if ret:
LOG.warning('Unable to get rados pool stats.')
return 'unknown', 'unknown'
ret, quota_outbuf, __ = client.cluster.mon_command(
'{"prefix":"osd pool get-quota", "pool": "%s",'
' "format":"json"}' % pool_name, '')
' "format":"json"}' % pool_name, b'')
if ret:
LOG.warning('Unable to get rados pool quotas.')
return 'unknown', 'unknown'

View File

@ -0,0 +1,7 @@
---
fixes:
- |
`Bug 1913449 <https://bugs.launchpad.net/cinder/+bug/1913449>`_:
Fix RBD driver _update_volume_stats() failing when using Ceph
Pacific python rados libraries. This failed because we
were passing a str instead of bytes to cluster.mon_command()