Skip to content

Commit bec6dd4

Browse files
tobias-urdinElod Illes
authored andcommitted
Stop leaking ceph df cmd in RBD utils
If the ceph df command fails in the get_pool_info method of RBD utils the actual command executed if seen by the users in the fault error message. This hides the command behind a StorageError exception and logs the exception instead of leaking it to the users. Change-Id: I6e3a73f2e04d1a7636daf96d5af73c9cf2fbe220 Closes-Bug: 1926978 (cherry picked from commit 86af7fe) (cherry picked from commit 5ede75c)
1 parent 66fb0ec commit bec6dd4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

nova/storage/rbd_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,14 @@ def get_pool_info(self):
405405
# MAX_AVAIL stat will divide by the replication size when doing the
406406
# calculation.
407407
args = ['ceph', 'df', '--format=json'] + self.ceph_args()
408-
out, _ = processutils.execute(*args)
408+
409+
try:
410+
out, _ = processutils.execute(*args)
411+
except processutils.ProcessExecutionError:
412+
LOG.exception('Could not determine disk usage')
413+
raise exception.StorageError(
414+
reason='Could not determine disk usage')
415+
409416
stats = jsonutils.loads(out)
410417

411418
# Find the pool for which we are configured.

nova/tests/unit/storage/test_rbd.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from eventlet import tpool
1515
import mock
16+
from oslo_concurrency import processutils
1617
from oslo_serialization import jsonutils
1718
from oslo_utils.fixture import uuidsentinel as uuids
1819

@@ -653,6 +654,11 @@ def test_get_pool_info(self, mock_execute):
653654
'used': ceph_df_json['pools'][1]['stats']['bytes_used']}
654655
self.assertDictEqual(expected, self.driver.get_pool_info())
655656

657+
@mock.patch('oslo_concurrency.processutils.execute', autospec=True,
658+
side_effect=processutils.ProcessExecutionError("failed"))
659+
def test_get_pool_info_execute_failed(self, mock_execute):
660+
self.assertRaises(exception.StorageError, self.driver.get_pool_info)
661+
656662
@mock.patch('oslo_concurrency.processutils.execute')
657663
def test_get_pool_info_not_found(self, mock_execute):
658664
# Make the pool something other than self.rbd_pool so it won't be found

0 commit comments

Comments
 (0)