From: Eric Harney Date: Mon, 9 Dec 2013 20:34:39 +0000 (-0500) Subject: NFS/GlusterFS: Skip incorrectly formatted shares X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=21ebf2898e2f5fc8127b7a3bdc9743c49933f952;p=openstack-build%2Fcinder-build.git NFS/GlusterFS: Skip incorrectly formatted shares Shares should always be of the form address:/volume. If they are not (i.e., are missing the '/'), then skip them and issue a warning message. This will prevent us from sending incorrect connection_info dicts to Nova. Closes-Bug: #1267253 Change-Id: Ic40cd0cdc862b44b0a7d3e5b1d7c4fee8ea1b28d --- diff --git a/cinder/tests/test_glusterfs.py b/cinder/tests/test_glusterfs.py index 69a616e09..9fa60efcb 100644 --- a/cinder/tests/test_glusterfs.py +++ b/cinder/tests/test_glusterfs.py @@ -244,6 +244,7 @@ class GlusterFsDriverTestCase(test.TestCase): config_data.append(self.TEST_EXPORT1) config_data.append('#' + self.TEST_EXPORT2) config_data.append(self.TEST_EXPORT2 + ' ' + self.TEST_EXPORT2_OPTIONS) + config_data.append('broken:share_format') config_data.append('') drv._read_config_file(self.TEST_SHARES_CONFIG_FILE).\ AndReturn(config_data) diff --git a/cinder/tests/test_nfs.py b/cinder/tests/test_nfs.py index b37cb6932..9e73d41e1 100644 --- a/cinder/tests/test_nfs.py +++ b/cinder/tests/test_nfs.py @@ -279,6 +279,7 @@ class NfsDriverTestCase(test.TestCase): config_data.append('') config_data.append(self.TEST_NFS_EXPORT2 + ' ' + self.TEST_NFS_EXPORT2_OPTIONS) + config_data.append('broken:share_format') drv._read_config_file(self.TEST_SHARES_CONFIG_FILE).\ AndReturn(config_data) mox.ReplayAll() diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py index bcc8e1420..24091f5ef 100644 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -15,6 +15,7 @@ import errno import os +import re from oslo.config import cfg @@ -295,6 +296,11 @@ class RemoteFsDriver(driver.VolumeDriver): share_address = share_info[0].strip().decode('unicode_escape') share_opts = share_info[1].strip() if len(share_info) > 1 else None + if not re.match(r'.+:/.+', share_address): + LOG.warn("Share %s ignored due to invalid format. Must be of " + "form address:/export." % share_address) + continue + self.shares[share_address] = share_opts LOG.debug("shares loaded: %s", self.shares)