diff options
author | Zuul <zuul@review.opendev.org> | 2021-07-09 03:08:56 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-07-09 03:08:56 +0000 |
commit | 4135970d3c62895662bbca5055c3a5ae4099bf7d (patch) | |
tree | 210af53420c68bb2ada5ca8c4cea629003104878 | |
parent | cf6288bbe4ae321d88b98e3c78e1d2ff22dc6bd9 (diff) | |
parent | bec6dd475243b027ce5ca487e1a9bffdb866d25f (diff) | |
download | nova-22.2.2.tar.gz |
Merge "Stop leaking ceph df cmd in RBD utils" into stable/victoria22.2.2
-rw-r--r-- | nova/storage/rbd_utils.py | 9 | ||||
-rw-r--r-- | nova/tests/unit/storage/test_rbd.py | 6 |
2 files changed, 14 insertions, 1 deletions
diff --git a/nova/storage/rbd_utils.py b/nova/storage/rbd_utils.py index 22bafe5053..431dfc9aec 100644 --- a/nova/storage/rbd_utils.py +++ b/nova/storage/rbd_utils.py @@ -405,7 +405,14 @@ class RBDDriver(object): # MAX_AVAIL stat will divide by the replication size when doing the # calculation. args = ['ceph', 'df', '--format=json'] + self.ceph_args() - out, _ = processutils.execute(*args) + + try: + out, _ = processutils.execute(*args) + except processutils.ProcessExecutionError: + LOG.exception('Could not determine disk usage') + raise exception.StorageError( + reason='Could not determine disk usage') + stats = jsonutils.loads(out) # Find the pool for which we are configured. diff --git a/nova/tests/unit/storage/test_rbd.py b/nova/tests/unit/storage/test_rbd.py index f0b3f70532..65796ebc1f 100644 --- a/nova/tests/unit/storage/test_rbd.py +++ b/nova/tests/unit/storage/test_rbd.py @@ -13,6 +13,7 @@ from eventlet import tpool import mock +from oslo_concurrency import processutils from oslo_serialization import jsonutils from oslo_utils.fixture import uuidsentinel as uuids @@ -653,6 +654,11 @@ class RbdTestCase(test.NoDBTestCase): 'used': ceph_df_json['pools'][1]['stats']['bytes_used']} self.assertDictEqual(expected, self.driver.get_pool_info()) + @mock.patch('oslo_concurrency.processutils.execute', autospec=True, + side_effect=processutils.ProcessExecutionError("failed")) + def test_get_pool_info_execute_failed(self, mock_execute): + self.assertRaises(exception.StorageError, self.driver.get_pool_info) + @mock.patch('oslo_concurrency.processutils.execute') def test_get_pool_info_not_found(self, mock_execute): # Make the pool something other than self.rbd_pool so it won't be found |