Browse code

Don't clobber all iSCSI connections during nova cleanup

The existing cleanup_nova() code inadvertently logs out of all iSCSI
connections on the machine because it does not pass the target name
as the -T parameter. This patch changes it to step through the targets
that match the pattern, logging out of each individually, and following
up with a delete op to cleanup the database.

Change-Id: I26c14acbe0e8de18f0e3bf7ad83b37379503e199

Dan Smith authored on 2013/03/29 04:22:25
Showing 1 changed files
... ...
@@ -156,8 +156,11 @@ function cleanup_nova() {
156 156
         fi
157 157
 
158 158
         # Logout and delete iscsi sessions
159
-        sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true
160
-        sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true
159
+        tgts=$(sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d ' ' -f2)
160
+        for target in $tgts; do
161
+            sudo iscsiadm --mode node -T $target --logout || true
162
+        done
163
+        sudo iscsiadm --mode node --op delete || true
161 164
 
162 165
         # Clean out the instances directory.
163 166
         sudo rm -rf $NOVA_INSTANCES_PATH/*