]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Scality SOFS: don't always read /proc/mounts twice
authorJordan Pittier <jordan.pittier@scality.com>
Fri, 27 Nov 2015 17:32:21 +0000 (18:32 +0100)
committerJordan Pittier <jordan.pittier@scality.com>
Mon, 4 Jan 2016 15:35:54 +0000 (15:35 +0000)
If the Scale Out FS is correcty mounted and found in /proc/mounts
then there's no need to read /proc/mounts again.

Change-Id: I8fa33cc80d2491d98986053f678cdf7983132bf9

cinder/tests/unit/test_scality.py
cinder/volume/drivers/scality.py

index c82cd9d655acdeda27ce94bb39d0482b5ef663ec..59787d7557216e8861f34c85c39b4ca4b7d666c0 100644 (file)
@@ -149,6 +149,21 @@ class ScalityDriverTestCase(test.TestCase):
                          _FAKE_MNT_POINT)
         self.assertEqual(expected_args, mock_execute.call_args[0])
 
+    @mock.patch("cinder.volume.utils.read_proc_mounts")
+    @mock.patch("oslo_concurrency.processutils.execute")
+    @mock.patch("oslo_utils.fileutils.ensure_tree", mock.Mock())
+    @mock.patch("os.symlink", mock.Mock())
+    def test_ensure_shares_mounted_when_sofs_mounted(self, mock_execute,
+                                                     mock_read_proc_mounts):
+        mock_read_proc_mounts.return_value = _FAKE_MOUNTS_TABLE[1]
+
+        self.drv._ensure_shares_mounted()
+
+        # Because SOFS is mounted from the beginning, we shouldn't read
+        # /proc/mounts more than once.
+        mock_read_proc_mounts.assert_called_once_with()
+        self.assertFalse(mock_execute.called)
+
     def test_find_share_when_no_shares_mounted(self):
         self.assertRaises(exception.RemoteFSNoSharesMounted,
                           self.drv._find_share, 'ignored')
index 0464555702827e2966866bad19b433fe66a685c2..64e4c93483f2016594a5a2b948208703340bb48b 100644 (file)
@@ -135,10 +135,11 @@ class ScalityDriver(remotefs_drv.RemoteFSSnapDriver):
         if not self._sofs_is_mounted():
             self._execute('mount', '-t', 'sofs', self.sofs_config,
                           self.sofs_mount_point, run_as_root=True)
-        if not self._sofs_is_mounted():
-            msg = _("Cannot mount Scality SOFS, check syslog for errors")
-            LOG.error(msg)
-            raise exception.VolumeBackendAPIException(data=msg)
+            # Check whether the mount command succeeded
+            if not self._sofs_is_mounted():
+                msg = _("Cannot mount Scality SOFS, check syslog for errors")
+                LOG.error(msg)
+                raise exception.VolumeBackendAPIException(data=msg)
 
         fileutils.ensure_tree(self.sofs_abs_volume_dir)