From d7bd65e8e9ff800d370effc1a8d24ea900a5d435 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Mon, 1 Dec 2014 13:29:02 -0700 Subject: [PATCH] Deal with tgt already exists errors This patch intends to provide a clear marker for ER in the case that create export fails due to the target entry already existing. Also this patch will enable us to go ahead and just use the existing target rather than bomb out and fail everything. Root cause of why we're getting a second create is still unknown and needs addressed, but this might help in getting more info as well as keeping things stable until we address the root issue. Change-Id: If96f4fab7d9709dbb0726b1dca6237d7bc66ecbe Partial-Bug: #1398078 --- cinder/brick/iscsi/iscsi.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cinder/brick/iscsi/iscsi.py b/cinder/brick/iscsi/iscsi.py index 14327baab..5c63de75c 100644 --- a/cinder/brick/iscsi/iscsi.py +++ b/cinder/brick/iscsi/iscsi.py @@ -246,10 +246,21 @@ class TgtAdm(TargetAdmin): LOG.warning(_LW("Failed to create iscsi target for volume " "id:%(vol_id)s: %(e)s") % {'vol_id': vol_id, 'e': e}) - - #Don't forget to remove the persistent file we created - os.unlink(volume_path) - raise exception.ISCSITargetCreateFailed(volume_id=vol_id) + if "target already exists" in err: + LOG.warning(_LW('Create iscsi target failed for ' + 'target already exists')) + # NOTE(jdg): We've run into some cases where the cmd being + # sent was not correct. May be related to using the + # executor direclty? + # Adding the additional Warning message above to provide + # a very cleary marker for ER, and if the tgt exists let's + # just try and use it and move along. + # Ref bug: #1398078 + pass + else: + # Don't forget to remove the persistent file we created + os.unlink(volume_path) + raise exception.ISCSITargetCreateFailed(volume_id=vol_id) iqn = '%s%s' % (self.iscsi_target_prefix, vol_id) tid = self._get_target(iqn) -- 2.45.2