From 674b86a5da2cfb8b294eb3296f36d5ffbb86ed4f Mon Sep 17 00:00:00 2001 From: Silvan Kaiser Date: Wed, 15 May 2019 12:58:30 +0200 Subject: [PATCH] Always use the current volume URL in the Quobyte driver Ensure all mounts use the currently configured quobyte_volume_url setting. Closes-Bug: #1828993 Change-Id: I109ab9b835be7bb9dbebc2d8973bad38723a93bd --- .../tests/unit/volume/drivers/test_quobyte.py | 2 +- cinder/volume/drivers/quobyte.py | 22 ++++++++++++------- .../notes/bug_1828993-8e78d7bbee16ca08.yaml | 5 +++++ 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/bug_1828993-8e78d7bbee16ca08.yaml diff --git a/cinder/tests/unit/volume/drivers/test_quobyte.py b/cinder/tests/unit/volume/drivers/test_quobyte.py index 1fb177e5d6b..9ef20b10f8c 100644 --- a/cinder/tests/unit/volume/drivers/test_quobyte.py +++ b/cinder/tests/unit/volume/drivers/test_quobyte.py @@ -555,7 +555,7 @@ class QuobyteDriverTestCase(test.TestCase): mock_get_mount_point.assert_called_once_with( self.TEST_QUOBYTE_VOLUME) mock_mount.assert_called_once_with( - self.TEST_QUOBYTE_VOLUME, + self.TEST_QUOBYTE_VOLUME_WITHOUT_PROTOCOL, mock_get_mount_point.return_value, ensure=True) diff --git a/cinder/volume/drivers/quobyte.py b/cinder/volume/drivers/quobyte.py index 339619854da..498ccc9c700 100644 --- a/cinder/volume/drivers/quobyte.py +++ b/cinder/volume/drivers/quobyte.py @@ -35,7 +35,7 @@ from cinder import utils from cinder.volume import configuration from cinder.volume.drivers import remotefs as remotefs_drv -VERSION = '1.1.11' +VERSION = '1.1.12' LOG = logging.getLogger(__name__) @@ -114,6 +114,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed): 1.1.9 - Support for Qemu >= 2.10.0 1.1.10 - Adds overlay based volumes for snapshot merge caching 1.1.11 - NAS secure ownership & permissions are now False by default + 1.1.12 - Ensure the currently configured volume url is always used """ @@ -244,6 +245,13 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed): {"cvol": os.path.join(cache_path, cache_file_name)}) fileutils.delete_if_exists(os.path.join(cache_path, cache_file_name)) + def _strip_qb_protocol(self, url): + # Strip quobyte:// from the URL + protocol = self.driver_volume_type + "://" + if url.startswith(protocol): + return url[len(protocol):] + return url + def do_setup(self, context): """Any initialization the volume driver does while starting.""" super(QuobyteDriver, self).do_setup(context) @@ -572,12 +580,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed): """ self.shares = {} - url = self.configuration.quobyte_volume_url - - # Strip quobyte:// from the URL - protocol = self.driver_volume_type + "://" - if url.startswith(protocol): - url = url[len(protocol):] + url = self._strip_qb_protocol(self.configuration.quobyte_volume_url) self.shares[url] = None # None = No extra mount options. @@ -589,7 +592,10 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed): :param quobyte_volume: string """ mount_path = self._get_mount_point_for_share(quobyte_volume) - self._mount_quobyte(quobyte_volume, mount_path, ensure=True) + # NOTE(kaisers): Always use the currently configured volume url + self._mount_quobyte( + self._strip_qb_protocol(self.configuration.quobyte_volume_url), + mount_path, ensure=True) @utils.synchronized('quobyte_ensure', external=False) def _ensure_shares_mounted(self): diff --git a/releasenotes/notes/bug_1828993-8e78d7bbee16ca08.yaml b/releasenotes/notes/bug_1828993-8e78d7bbee16ca08.yaml new file mode 100644 index 00000000000..84634d53d41 --- /dev/null +++ b/releasenotes/notes/bug_1828993-8e78d7bbee16ca08.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes a bug that could cause mount failures with the Quobyte driver if + the quobyte_volume_url setting was changed in a running system.