From 9fe9afb1590eb4c42969e537a610e0b796b4f1fd Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 14 Jun 2013 08:15:28 -0400 Subject: [PATCH] deploy element: Call find_disk in loop w/ timeout. Updates our deploy element's init script so that it calls find_disk in a loop until it returns true (meaning we have a disk). Previously on some bare metal machines find_disk would return "" which causes the subsequent iscsi target commands to fail due to a bad backing store. This commit also updates the error message when start_iscsi_target fails to be a bit more accurate as well. Fixes LP Bug #1190984. Change-Id: I3cd535d6672c197c1c3c539c83bba36be7a14e18 --- elements/deploy/init | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/elements/deploy/init b/elements/deploy/init index 7a5e26da..30ff3287 100644 --- a/elements/deploy/init +++ b/elements/deploy/init @@ -4,11 +4,25 @@ if [ -z "$ISCSI_TARGET_IQN" ]; then bash fi -target_disk=`find_disk "$DISK"` +t=0 +while ! target_disk=$(find_disk "$DISK"); do + if [ $t -eq 10 ]; then + break + fi + t=$(($t + 1)) + sleep 1 +done + +if [ -z "$target_disk" ]; then + echo "Could not find disk to use." + echo "Starting troubleshooting shell." + bash +fi + echo "start iSCSI target on $target_disk" start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL if [ $? -ne 0 ]; then - echo "Could not find disk to use." + echo "Failed to start iscsi target." echo "Starting troubleshooting shell." bash fi