From 4645123cadc441ed138355d94823310255f548ba Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 25 Mar 2013 12:46:51 -0700 Subject: [PATCH] Force deletes using tgt to workaround bug 1159948 Tgt has a bug where it can have multiple copies of an initiator if there has been a reconnect. See https://bugs.launchpad.net/cinder/+bug/1159948 Change-Id: I9a1b6757eb780efbaa1403016e50de7c0e45d720 (cherry picked from commit b84218633ab5417adf94c568eb54243f4074ab11) --- cinder/tests/test_iscsi.py | 3 ++- cinder/volume/iscsi.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cinder/tests/test_iscsi.py b/cinder/tests/test_iscsi.py index 4bd9428523..15bc7cc637 100644 --- a/cinder/tests/test_iscsi.py +++ b/cinder/tests/test_iscsi.py @@ -101,7 +101,8 @@ def setUp(self): self.flags(volumes_dir=self.persist_tempdir) self.script_template = "\n".join([ 'tgt-admin --update iqn.2011-09.org.foo.bar:blaa', - 'tgt-admin --delete iqn.2010-10.org.openstack:volume-blaa']) + 'tgt-admin --force ' + '--delete iqn.2010-10.org.openstack:volume-blaa']) def tearDown(self): try: diff --git a/cinder/volume/iscsi.py b/cinder/volume/iscsi.py index ae664b767b..d231de8f65 100644 --- a/cinder/volume/iscsi.py +++ b/cinder/volume/iscsi.py @@ -190,7 +190,10 @@ def remove_iscsi_target(self, tid, lun, vol_id, **kwargs): else: raise exception.ISCSITargetRemoveFailed(volume_id=vol_id) try: + # NOTE(vish): --force is a workaround for bug: + # https://bugs.launchpad.net/cinder/+bug/1159948 self._execute('tgt-admin', + '--force', '--delete', iqn, run_as_root=True)