]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Catch new iscsi exception
authorJohn Griffith <john.griffith@solidfire.com>
Fri, 24 Jan 2014 21:51:21 +0000 (14:51 -0700)
committerjohn-griffith <john.griffith@solidfire.com>
Sat, 25 Jan 2014 01:21:01 +0000 (18:21 -0700)
A while back we fixed up a target create/update error
that was identified in the gating tests:
    https://review.openstack.org/#/c/47513/

Since then a new patch was introduced to to the update and separate
it so that it could easily be used in other places.
    https://review.openstack.org/#/c/58599/

The problem is this added a new exception "TargetUpdate" and
didn't add this to the except block that we have.

This patch changes the catch block to handle the new exception and
do the retry, thereby putting the original fix back in place.

Change-Id: I1ed1bc6f4249f99a36b1168f9fec0b6b74482acf
Closes-Bug: 1223469

cinder/brick/iscsi/iscsi.py
cinder/volume/drivers/lvm.py

index a3fcc62065fa95b80c488c1d2efdb0b0cb584c9a..ceac1b9c2c4be0eb7cdb52800b36b55bb05095e5 100644 (file)
@@ -184,6 +184,10 @@ class TgtAdm(TargetAdmin):
             old_persist_file = os.path.join(volumes_dir, old_name)
 
         try:
+            # with the persistent tgts we create them
+            # by creating the entry in the persist file
+            # and then doing an update to get the target
+            # created.
             self.update_iscsi_target(name)
 
             # Grab targets list for debug
@@ -198,7 +202,8 @@ class TgtAdm(TargetAdmin):
                                        'target',
                                        run_as_root=True)
             LOG.debug("Targets after update: %s" % out)
-        except putils.ProcessExecutionError as e:
+        except (putils.ProcessExecutionError,
+                exception.ISCSITargetUpdateFailed) as e:
             LOG.warning(_("Failed to create iscsi target for volume "
                         "id:%(vol_id)s: %(e)s")
                         % {'vol_id': vol_id, 'e': str(e)})
@@ -250,8 +255,8 @@ class TgtAdm(TargetAdmin):
         except putils.ProcessExecutionError as e:
             LOG.error(_("Failed to update iscsi target %(name)s: %(e)s") %
                       {'name': name, 'e': str(e)})
-            LOG.debug("StdOut from tgt-admin --update: %s", e.stdout)
-            LOG.debug("StdErr from tgt-admin --update: %s", e.stderr)
+            LOG.error("StdOut from tgt-admin --update: %s", e.stdout)
+            LOG.error("StdErr from tgt-admin --update: %s", e.stderr)
             raise exception.ISCSITargetUpdateFailed(name=name)
 
     def remove_iscsi_target(self, tid, lun, vol_id, vol_name, **kwargs):
index 57a1703394ed0d1c0be2bc30f5b9199ed2d966f2..61fa1d12fb508634fe16cc6898c3e7c2eb64e2d7 100644 (file)
@@ -371,11 +371,17 @@ class LVMVolumeDriver(driver.VolumeDriver):
         data["driver_version"] = self.VERSION
         data["storage_protocol"] = self.protocol
 
-        data['total_capacity_gb'] = float(self.vg.vg_size)
-        data['free_capacity_gb'] = float(self.vg.vg_free_space)
-        if self.configuration.lvm_type == 'thin':
+        if self.configuration.lvm_mirrors > 0:
+            data['total_capacity_gb'] =\
+                self.vg.vg_mirror_size(self.configuration.lvm_mirrors)
+            data['free_capacity_gb'] =\
+                self.vg.vg_mirror_free_space(self.configuration.lvm_mirrors)
+        elif self.configuration.lvm_type == 'thin':
             data['total_capacity_gb'] = float(self.vg.vg_thin_pool_size)
             data['free_capacity_gb'] = float(self.vg.vg_thin_pool_free_space)
+        else:
+            data['total_capacity_gb'] = float(self.vg.vg_size)
+            data['free_capacity_gb'] = float(self.vg.vg_free_space)
         data['reserved_percentage'] = self.configuration.reserved_percentage
         data['QoS_support'] = False
         data['location_info'] =\
@@ -755,7 +761,13 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
         # update the iSCSI target
         iscsi_name = "%s%s" % (self.configuration.iscsi_target_prefix,
                                volume['name'])
-        self.tgtadm.update_iscsi_target(iscsi_name)
+        try:
+            self.tgtadm.update_iscsi_target(iscsi_name)
+        except brick_exception.ISCSITargetUpdateFailed as e:
+            msg = (_('Failed to initialize iscsi '
+                     'connection for target: %s.') % iscsi_name)
+            LOG.error(msg)
+            raise exception.VolumeBackendAPIException(data=msg)
 
         # continue with the base class behaviour
         return driver.ISCSIDriver.initialize_connection(self,