From 18f8f5be94aae3b1747b143479ea1b188872f000 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Fri, 24 Jan 2014 14:51:21 -0700 Subject: [PATCH] Catch new iscsi exception 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 | 11 ++++++++--- cinder/volume/drivers/lvm.py | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/cinder/brick/iscsi/iscsi.py b/cinder/brick/iscsi/iscsi.py index a3fcc6206..ceac1b9c2 100644 --- a/cinder/brick/iscsi/iscsi.py +++ b/cinder/brick/iscsi/iscsi.py @@ -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): diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 57a170339..61fa1d12f 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -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, -- 2.45.2