From 0132be46bc9b4bb1b3bf77a623cc1d3b7e9307ea Mon Sep 17 00:00:00 2001 From: john-griffith Date: Tue, 28 Jan 2014 21:30:59 -0700 Subject: [PATCH] Revert initialize_connection changes A change was merged that reusulted in interittent gate failures. It seems that in certain cases the intitialize is doing an update targets and is deleting the existing targets and not recreating them. The idea of this patch was to fix up the iscis targets for cases where volumes are extended. A better solution is in progress that will remove the target creation from the create_volume process altogether. Currently we seem to have create_export, ensure_export and now initialize that all are designed to do very similar things. A bug has been filed to address this and will attempt to collapse these functions to be done at attach time. This particular patch in essence reverts two patches: commit: 18f8f5be94aae3b1747b143479ea1b188872f000 commit: a9267644ee09591e2d642d6c1204d94a9fdd8c82 Change-Id: Ib615847f3cbeb74b1e4416d51730162ad1d07a40 Closes-Bug: 1270608 --- cinder/brick/exception.py | 4 ---- cinder/brick/iscsi/iscsi.py | 25 +++++-------------------- cinder/volume/drivers/lvm.py | 24 ------------------------ 3 files changed, 5 insertions(+), 48 deletions(-) diff --git a/cinder/brick/exception.py b/cinder/brick/exception.py index b32eb1324..3d6e014dc 100644 --- a/cinder/brick/exception.py +++ b/cinder/brick/exception.py @@ -105,10 +105,6 @@ class ISCSITargetCreateFailed(BrickException): message = _("Failed to create iscsi target for volume %(volume_id)s.") -class ISCSITargetUpdateFailed(BrickException): - message = _("Failed to update iscsi target for volume %(name)s.") - - class ISCSITargetRemoveFailed(BrickException): message = _("Failed to remove iscsi target for volume %(volume_id)s.") diff --git a/cinder/brick/iscsi/iscsi.py b/cinder/brick/iscsi/iscsi.py index ceac1b9c2..33939eb39 100644 --- a/cinder/brick/iscsi/iscsi.py +++ b/cinder/brick/iscsi/iscsi.py @@ -188,7 +188,10 @@ class TgtAdm(TargetAdmin): # by creating the entry in the persist file # and then doing an update to get the target # created. - self.update_iscsi_target(name) + (out, err) = self._execute('tgt-admin', '--update', name, + run_as_root=True) + LOG.debug("StdOut from tgt-admin --update: %s", out) + LOG.debug("StdErr from tgt-admin --update: %s", err) # Grab targets list for debug # Consider adding a check for lun 0 and 1 for tgtadm @@ -202,8 +205,7 @@ class TgtAdm(TargetAdmin): 'target', run_as_root=True) LOG.debug("Targets after update: %s" % out) - except (putils.ProcessExecutionError, - exception.ISCSITargetUpdateFailed) as e: + except putils.ProcessExecutionError as e: LOG.warning(_("Failed to create iscsi target for volume " "id:%(vol_id)s: %(e)s") % {'vol_id': vol_id, 'e': str(e)}) @@ -245,20 +247,6 @@ class TgtAdm(TargetAdmin): return tid - def update_iscsi_target(self, name): - - LOG.info(_('Updating iscsi target: %s') % name) - - try: - (out, err) = self._execute('tgt-admin', '--update', name, - run_as_root=True) - except putils.ProcessExecutionError as e: - LOG.error(_("Failed to update iscsi target %(name)s: %(e)s") % - {'name': name, 'e': str(e)}) - 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): LOG.info(_('Removing iscsi_target for: %s') % vol_id) vol_uuid_file = vol_name @@ -447,9 +435,6 @@ class FakeIscsiHelper(object): self.tid += 1 return self.tid - def update_iscsi_target(self, name): - return - class LioAdm(TargetAdmin): """iSCSI target administration for LIO using python-rtslib.""" diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 61fa1d12f..0d7369146 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -750,30 +750,6 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver): def _iscsi_authentication(self, chap, name, password): return "%s %s %s" % (chap, name, password) - def initialize_connection(self, volume, connector): - """Initializes the connection and returns connection info. - - This function overrides the base class implementation so that the iSCSI - target can be updated. This is necessary in the event that a user - extended the volume before attachement. - """ - - # update the iSCSI target - iscsi_name = "%s%s" % (self.configuration.iscsi_target_prefix, - volume['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, - volume, - connector) - class LVMISERDriver(LVMISCSIDriver, driver.ISERDriver): """Executes commands relating to ISER volumes. -- 2.45.2