Skip to content

Commit 82141b1

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Stop leaking ceph df cmd in RBD utils"
2 parents 5592d31 + 86af7fe commit 82141b1

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
@@ -425,7 +425,14 @@ def get_pool_info(self):
425425
# MAX_AVAIL stat will divide by the replication size when doing the
426426
# calculation.
427427
args = ['ceph', 'df', '--format=json'] + self.ceph_args()
428-
out, _ = processutils.execute(*args)
428+
429+
try:
430+
out, _ = processutils.execute(*args)
431+
except processutils.ProcessExecutionError:
432+
LOG.exception('Could not determine disk usage')
433+
raise exception.StorageError(
434+
reason='Could not determine disk usage')
435+
429436
stats = jsonutils.loads(out)
430437

431438
# 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)