From f9ebdbf09d331a683a26b5e626fac0888e7317b9 Mon Sep 17 00:00:00 2001 From: Pavel Glushchak Date: Thu, 20 Apr 2017 18:43:14 +0300 Subject: [PATCH] VStorage: make logging path configurable Logging path can now be configured in shares config file. When it's not set, the default logging path is appended to mount options. Also default logging path is changed because of: When VStorage package is installed, default logging path /var/log/vstorage is created. So this should be a default value for logging path. Otherwise user is forced to create logging path manually, because share mount will fail. Change-Id: Iba837bdd6bbf991d91f43f61f62fffebbc1877ae Signed-off-by: Pavel Glushchak --- .../unit/volume/drivers/test_vzstorage.py | 24 +++++++++++++------ cinder/volume/drivers/vzstorage.py | 20 ++++++++++------ .../vzstorage-log-path-7539342e562a2e4a.yaml | 8 +++++++ 3 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/vzstorage-log-path-7539342e562a2e4a.yaml diff --git a/cinder/tests/unit/volume/drivers/test_vzstorage.py b/cinder/tests/unit/volume/drivers/test_vzstorage.py index 5c4d5efcacd..d18d8499571 100644 --- a/cinder/tests/unit/volume/drivers/test_vzstorage.py +++ b/cinder/tests/unit/volume/drivers/test_vzstorage.py @@ -56,10 +56,6 @@ class VZStorageTestCase(test.TestCase): def setUp(self): super(VZStorageTestCase, self).setUp() - self._remotefsclient = mock.patch.object( - remotefs, 'VZStorageRemoteFSClient').start() - get_mount_point = mock.Mock(return_value=self._FAKE_MNT_POINT) - self._remotefsclient.get_mount_point = get_mount_point cfg = copy.copy(self._FAKE_VZ_CONFIG) self._vz_driver = vzstorage.VZStorageDriver(configuration=cfg) self._vz_driver._local_volume_dir = mock.Mock( @@ -168,12 +164,26 @@ class VZStorageTestCase(test.TestCase): self.assertRaises(exception.VzStorageException, self._vz_driver._ensure_share_mounted, ':') - def test_ensure_share_mounted(self): + @mock.patch.object(remotefs.RemoteFsClient, 'mount') + def test_ensure_share_mounted(self, mock_mount): drv = self._vz_driver - share = self._FAKE_SHARE - drv.shares = {'1': '["1", "2", "3"]', share: '["some", "options"]'} + share = 'test' + expected_calls = [ + mock.call(share, ['-u', 'cinder', '-g', 'root', '-l', + '/var/log/vstorage/%s/cinder.log.gz' % share]), + mock.call(share, ['-l', '/var/log/dummy.log']) + ] + + share_flags = '["-u", "cinder", "-g", "root"]' + drv.shares[share] = share_flags drv._ensure_share_mounted(share) + share_flags = '["-l", "/var/log/dummy.log"]' + drv.shares[share] = share_flags + drv._ensure_share_mounted(share) + + mock_mount.assert_has_calls(expected_calls) + def test_find_share(self): drv = self._vz_driver drv._mounted_shares = [self._FAKE_SHARE] diff --git a/cinder/volume/drivers/vzstorage.py b/cinder/volume/drivers/vzstorage.py index 5cc1b5092b3..c478f3c2458 100644 --- a/cinder/volume/drivers/vzstorage.py +++ b/cinder/volume/drivers/vzstorage.py @@ -300,13 +300,19 @@ class VZStorageDriver(remotefs_drv.RemoteFSSnapDriver): raise exception.VzStorageException(msg) cluster_name = m.group(2) - # set up logging to non-default path, so that it will - # be possible to mount the same cluster to another mount - # point by hand with default options. - mnt_flags = ['-l', '/var/log/pstorage/%s-cinder.log.gz' % cluster_name] - if self.shares.get(share) is not None: - extra_flags = json.loads(self.shares[share]) - mnt_flags.extend(extra_flags) + if share in self.shares: + mnt_flags = json.loads(self.shares[share]) + else: + mnt_flags = [] + + if '-l' not in mnt_flags: + # If logging path is not specified in shares config + # set up logging to non-default path, so that it will + # be possible to mount the same cluster to another mount + # point by hand with default options. + mnt_flags.extend([ + '-l', '/var/log/vstorage/%s/cinder.log.gz' % cluster_name]) + self._remotefsclient.mount(share, mnt_flags) def _find_share(self, volume): diff --git a/releasenotes/notes/vzstorage-log-path-7539342e562a2e4a.yaml b/releasenotes/notes/vzstorage-log-path-7539342e562a2e4a.yaml new file mode 100644 index 00000000000..3d55e43478d --- /dev/null +++ b/releasenotes/notes/vzstorage-log-path-7539342e562a2e4a.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Logging path can now be configured for vzstorage driver in + shares config file (specified by vzstorage_shares_config option). + To set custom logging path add `'-l', ''` to + mount options array. Otherwise default logging path + `/var/log/vstorage//cinder.log.gz` will be used.