]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Netapp: fix multiple copies of cinder-volume
authorVishvananda Ishaya <vishvananda@gmail.com>
Tue, 9 Sep 2014 00:05:13 +0000 (17:05 -0700)
committerVishvananda Ishaya <vishvananda@gmail.com>
Tue, 9 Sep 2014 00:05:13 +0000 (17:05 -0700)
Various commands were failing when running multiple copies of
cinder-volume. This is due to storing an in memory copy of the luns
which may get updated in the backend by another cinder-volume. Fix
it by attempting to refresh the list of luns if one is not found
during a request.

Change-Id: Iecd1dc5146525d7240a09f71669a3ab239c488bd
Resolves-bug: #1367044

cinder/volume/drivers/netapp/iscsi.py

index 761c79d46e953a36bc8aa8e693dff109e3260edc..7dbed37814f0d99f345296daefde2b2bc2b13b03 100644 (file)
@@ -282,7 +282,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
 
         vol_name = snapshot['volume_name']
         snapshot_name = snapshot['name']
-        lun = self.lun_table[vol_name]
+        lun = self._get_lun_from_table(vol_name)
         self._clone_lun(lun.name, snapshot_name, 'false')
 
     def delete_snapshot(self, snapshot):
@@ -545,7 +545,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
     def create_cloned_volume(self, volume, src_vref):
         """Creates a clone of the specified volume."""
         vol_size = volume['size']
-        src_vol = self.lun_table[src_vref['name']]
+        src_vol = self._get_lun_from_table(src_vref['name'])
         src_vol_size = src_vref['size']
         new_name = volume['name']
         self._clone_lun(src_vol.name, new_name, 'true')
@@ -576,8 +576,9 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
     def extend_volume(self, volume, new_size):
         """Extend an existing volume to the new size."""
         name = volume['name']
-        path = self.lun_table[name].metadata['Path']
-        curr_size_bytes = str(self.lun_table[name].size)
+        lun = self._get_lun_from_table(name)
+        path = lun.metadata['Path']
+        curr_size_bytes = str(lun.size)
         new_size_bytes = str(int(new_size) * units.Gi)
         # Reused by clone scenarios.
         # Hence comparing the stored size.
@@ -671,7 +672,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
         LOG.info(_("Resizing lun %s using sub clone to new size."), seg[-1])
         name = seg[-1]
         vol_name = seg[2]
-        lun = self.lun_table[name]
+        lun = self._get_lun_from_table(name)
         metadata = lun.metadata
         compression = self._get_vol_option(vol_name, 'compression')
         if compression == "on":
@@ -1130,7 +1131,10 @@ class NetAppDirectCmodeISCSIDriver(NetAppDirectISCSIDriver):
 
     def delete_volume(self, volume):
         """Driver entry point for destroying existing volumes."""
-        lun = self.lun_table.get(volume['name'])
+        try:
+            lun = self._get_lun_from_table(volume['name'])
+        except exception.VolumeNotFound:
+            lun = None
         netapp_vol = None
         if lun:
             netapp_vol = lun.get_metadata_property('Volume')