Browse Source

Check ceph backend connection on driver setup

Check that ceph connection really works when setting up
the driver instead of doing real connect later in init_host
phase. This mitigates the risk that the service crashes/respawns
in an infinite loop because of a connection error.

Change-Id: Ia71b55dab1535ce351310108aaf53304b15ab757
Closes-Bug: 1640169
changes/61/394961/4
Jan Provaznik 5 years ago
parent
commit
af79b9f5b7
  1. 5
      manila/share/drivers/cephfs/cephfs_native.py
  2. 12
      manila/tests/share/drivers/cephfs/test_cephfs_native.py
  3. 4
      releasenotes/notes/bug-1640169-check-ceph-connection-on-setup-c92bde41ced43326.yaml

5
manila/share/drivers/cephfs/cephfs_native.py

@ -82,6 +82,11 @@ class CephFSNativeDriver(driver.ShareDriver,):
self.configuration.append_config_values(cephfs_native_opts)
def check_for_setup_error(self):
# NOTE: make sure that we can really connect to the ceph,
# otherwise an exception is raised
self.volume_client
def _update_share_stats(self):
stats = self.volume_client.rados.get_cluster_stats()

12
manila/tests/share/drivers/cephfs/test_cephfs_native.py

@ -449,3 +449,15 @@ class CephFSNativeDriverTestCase(test.TestCase):
self._driver.create_share,
self._context,
self._share)
def test_check_for_setup_error(self):
self._driver.check_for_setup_error()
self._driver._volume_client.connect.assert_called_once_with(
premount_evict='manila')
def test_check_for_setup_error_with_connection_error(self):
cephfs_native.ceph_module_found = False
cephfs_native.ceph_volume_client = None
self.assertRaises(exception.ManilaException,
self._driver.check_for_setup_error)

4
releasenotes/notes/bug-1640169-check-ceph-connection-on-setup-c92bde41ced43326.yaml

@ -0,0 +1,4 @@
---
fixes:
- Added a check on driver startup for CEPHFS back ends to verify whether
the back end is accessible.
Loading…
Cancel
Save