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
This commit is contained in:
John Griffith 2014-12-01 13:29:02 -07:00
parent 7e3ddf8d0d
commit d7bd65e8e9
1 changed files with 15 additions and 4 deletions

View File

@ -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)