From c0fad2b6a1729e7b1e7c6f892d6cac9d4a086433 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Thu, 28 Mar 2013 12:22:25 -0700 Subject: [PATCH] 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 --- lib/nova | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/nova b/lib/nova index 4449f81674..46eeea49d4 100644 --- a/lib/nova +++ b/lib/nova @@ -156,8 +156,11 @@ function cleanup_nova() { fi # Logout and delete iscsi sessions - sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true - sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true + tgts=$(sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d ' ' -f2) + for target in $tgts; do + sudo iscsiadm --mode node -T $target --logout || true + done + sudo iscsiadm --mode node --op delete || true # Clean out the instances directory. sudo rm -rf $NOVA_INSTANCES_PATH/*