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 <pglushchak@virtuozzo.com>
This commit is contained in:
parent
4b9bc833d1
commit
f9ebdbf09d
@ -56,10 +56,6 @@ class VZStorageTestCase(test.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(VZStorageTestCase, self).setUp()
|
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)
|
cfg = copy.copy(self._FAKE_VZ_CONFIG)
|
||||||
self._vz_driver = vzstorage.VZStorageDriver(configuration=cfg)
|
self._vz_driver = vzstorage.VZStorageDriver(configuration=cfg)
|
||||||
self._vz_driver._local_volume_dir = mock.Mock(
|
self._vz_driver._local_volume_dir = mock.Mock(
|
||||||
@ -168,12 +164,26 @@ class VZStorageTestCase(test.TestCase):
|
|||||||
self.assertRaises(exception.VzStorageException,
|
self.assertRaises(exception.VzStorageException,
|
||||||
self._vz_driver._ensure_share_mounted, ':')
|
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
|
drv = self._vz_driver
|
||||||
share = self._FAKE_SHARE
|
share = 'test'
|
||||||
drv.shares = {'1': '["1", "2", "3"]', share: '["some", "options"]'}
|
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)
|
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):
|
def test_find_share(self):
|
||||||
drv = self._vz_driver
|
drv = self._vz_driver
|
||||||
drv._mounted_shares = [self._FAKE_SHARE]
|
drv._mounted_shares = [self._FAKE_SHARE]
|
||||||
|
@ -300,13 +300,19 @@ class VZStorageDriver(remotefs_drv.RemoteFSSnapDriver):
|
|||||||
raise exception.VzStorageException(msg)
|
raise exception.VzStorageException(msg)
|
||||||
cluster_name = m.group(2)
|
cluster_name = m.group(2)
|
||||||
|
|
||||||
# set up logging to non-default path, so that it will
|
if share in self.shares:
|
||||||
# be possible to mount the same cluster to another mount
|
mnt_flags = json.loads(self.shares[share])
|
||||||
# point by hand with default options.
|
else:
|
||||||
mnt_flags = ['-l', '/var/log/pstorage/%s-cinder.log.gz' % cluster_name]
|
mnt_flags = []
|
||||||
if self.shares.get(share) is not None:
|
|
||||||
extra_flags = json.loads(self.shares[share])
|
if '-l' not in mnt_flags:
|
||||||
mnt_flags.extend(extra_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)
|
self._remotefsclient.mount(share, mnt_flags)
|
||||||
|
|
||||||
def _find_share(self, volume):
|
def _find_share(self, volume):
|
||||||
|
@ -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', '<path_to_log_file>'` to
|
||||||
|
mount options array. Otherwise default logging path
|
||||||
|
`/var/log/vstorage/<cluster_name>/cinder.log.gz` will be used.
|
Loading…
Reference in New Issue
Block a user