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
This commit is contained in:
Eric Harney 2021-02-02 09:23:25 -05:00
parent 677ee75d5d
commit 11704d0e8c
3 changed files with 13 additions and 6 deletions

View File

@ -1544,9 +1544,9 @@ class RBDTestCase(test.TestCase):
return_value=dynamic_total): return_value=dynamic_total):
result = self.driver._get_pool_stats() result = self.driver._get_pool_stats()
client.cluster.mon_command.assert_has_calls([ 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",' mock.call('{"prefix":"osd pool get-quota", "pool": "rbd",'
' "format":"json"}', ''), ' "format":"json"}', b''),
]) ])
self.assertEqual((free_capacity, total_capacity), result) self.assertEqual((free_capacity, total_capacity), result)
@ -1567,9 +1567,9 @@ class RBDTestCase(test.TestCase):
] ]
result = self.driver._get_pool_stats() result = self.driver._get_pool_stats()
client.cluster.mon_command.assert_has_calls([ 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",' mock.call('{"prefix":"osd pool get-quota", "pool": "rbd",'
' "format":"json"}', ''), ' "format":"json"}', b''),
]) ])
free_capacity = 1.56 free_capacity = 1.56
total_capacity = 3.0 total_capacity = 3.0

View File

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