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
This commit is contained in:
Jan Provaznik 2016-11-08 14:37:06 +01:00
parent 5dfeebb536
commit af79b9f5b7
3 changed files with 21 additions and 0 deletions

View File

@ -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()

View File

@ -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)

View File

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