]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NFS/GlusterFS: Skip incorrectly formatted shares
authorEric Harney <eharney@redhat.com>
Mon, 9 Dec 2013 20:34:39 +0000 (15:34 -0500)
committerEric Harney <eharney@redhat.com>
Wed, 8 Jan 2014 21:24:49 +0000 (16:24 -0500)
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

cinder/tests/test_glusterfs.py
cinder/tests/test_nfs.py
cinder/volume/drivers/nfs.py

index 69a616e0921896fe1f29ae5151670e6914c2d41b..9fa60efcb707c8474d66173669660b99384a582f 100644 (file)
@@ -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)
index b37cb6932a448c58bc4308b42fdc9b7a89926388..9e73d41e1916a815ca48dff82cf87982271ef409 100644 (file)
@@ -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()
index bcc8e1420abfb54787ea4687e13ac427c32bd439..24091f5efadeafe73ecde849cd0e8f6930569607 100644 (file)
@@ -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)