From ca25d7af9768182723a64fd26be3a8a41142c001 Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Fri, 5 Aug 2016 22:23:34 +0300 Subject: [PATCH] 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 --- cinder/backup/drivers/nfs.py | 2 +- cinder/tests/unit/backup/drivers/test_backup_nfs.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cinder/backup/drivers/nfs.py b/cinder/backup/drivers/nfs.py index da000fba21a..1a7b4fd5689 100644 --- a/cinder/backup/drivers/nfs.py +++ b/cinder/backup/drivers/nfs.py @@ -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, diff --git a/cinder/tests/unit/backup/drivers/test_backup_nfs.py b/cinder/tests/unit/backup/drivers/test_backup_nfs.py index 3b7696720cb..19a35af38b0 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_nfs.py +++ b/cinder/tests/unit/backup/drivers/test_backup_nfs.py @@ -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)