Fix backup NFS share mount with default backup_mount_options

Now, if backup_mount_options in not set, NFS Backup driver
passes empty dict to RemoteFsClient. It cause an error when
RemoteFsClient mounts the share because it passes '-o {}' params.

According to [1] we should pass None to RemoteFsClient if no
backup_mount_options was specified.

[1] https://github.com/openstack/os-brick/blob/master/os_brick/remotefs/remotefs.py#L129-L130

Change-Id: Ief874332a71ff77c88a65e2d631457b831472236
Closes-Bug: #1529566
(cherry picked from commit ca25d7af97)
This commit is contained in:
Ivan Kolodyazhny 2016-08-05 22:23:34 +03:00
parent ec26f2a720
commit 5b387121f1
2 changed files with 10 additions and 4 deletions

View File

@ -53,7 +53,7 @@ class NFSBackupDriver(posix.PosixBackupDriver):
self._check_configuration()
self.backup_mount_point_base = CONF.backup_mount_point_base
self.backup_share = CONF.backup_share
self.mount_options = CONF.backup_mount_options or {}
self.mount_options = CONF.backup_mount_options
backup_path = self._init_backup_repo_path()
LOG.debug("Using NFS backup repository: %s", backup_path)
super(NFSBackupDriver, self).__init__(context,

View File

@ -73,7 +73,8 @@ class BackupNFSShareTestCase(test.TestCase):
self.assertRaises(exception.ConfigNotFound,
driver._check_configuration)
def test_init_backup_repo_path(self):
@mock.patch.object(remotefs_brick, 'RemoteFsClient')
def test_init_backup_repo_path(self, mock_remotefs_client_class):
self.override_config('backup_share', FAKE_BACKUP_SHARE)
self.override_config('backup_mount_point_base',
FAKE_BACKUP_MOUNT_POINT_BASE)
@ -81,8 +82,7 @@ class BackupNFSShareTestCase(test.TestCase):
mock_remotefsclient.get_mount_point = mock.Mock(
return_value=FAKE_BACKUP_PATH)
self.mock_object(nfs.NFSBackupDriver, '_check_configuration')
self.mock_object(remotefs_brick, 'RemoteFsClient',
mock.Mock(return_value=mock_remotefsclient))
mock_remotefs_client_class.return_value = mock_remotefsclient
self.mock_object(utils, 'get_root_helper')
with mock.patch.object(nfs.NFSBackupDriver, '_init_backup_repo_path'):
driver = nfs.NFSBackupDriver(self.ctxt)
@ -91,6 +91,12 @@ class BackupNFSShareTestCase(test.TestCase):
self.assertEqual(FAKE_BACKUP_PATH, path)
utils.get_root_helper.called_once()
mock_remotefs_client_class.assert_called_once_with(
'nfs',
utils.get_root_helper(),
nfs_mount_point_base=FAKE_BACKUP_MOUNT_POINT_BASE,
nfs_mount_options=None
)
mock_remotefsclient.mount.assert_called_once_with(FAKE_BACKUP_SHARE)
mock_remotefsclient.get_mount_point.assert_called_once_with(
FAKE_BACKUP_SHARE)