From af79b9f5b78be5413bc363cbf12ae8351b9e4f02 Mon Sep 17 00:00:00 2001 From: Jan Provaznik Date: Tue, 8 Nov 2016 14:37:06 +0100 Subject: [PATCH] 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 --- manila/share/drivers/cephfs/cephfs_native.py | 5 +++++ .../tests/share/drivers/cephfs/test_cephfs_native.py | 12 ++++++++++++ ...ck-ceph-connection-on-setup-c92bde41ced43326.yaml | 4 ++++ 3 files changed, 21 insertions(+) create mode 100644 releasenotes/notes/bug-1640169-check-ceph-connection-on-setup-c92bde41ced43326.yaml 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.