diff --git a/manila/share/drivers/cephfs/cephfs_native.py b/manila/share/drivers/cephfs/cephfs_native.py index 06d7e5b6..ddce19f4 100644 --- a/manila/share/drivers/cephfs/cephfs_native.py +++ b/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() diff --git a/manila/tests/share/drivers/cephfs/test_cephfs_native.py b/manila/tests/share/drivers/cephfs/test_cephfs_native.py index 203f3c28..3756cdb4 100644 --- a/manila/tests/share/drivers/cephfs/test_cephfs_native.py +++ b/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) diff --git a/releasenotes/notes/bug-1640169-check-ceph-connection-on-setup-c92bde41ced43326.yaml b/releasenotes/notes/bug-1640169-check-ceph-connection-on-setup-c92bde41ced43326.yaml new file mode 100644 index 00000000..b45b495f --- /dev/null +++ b/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.