Make bash troubleshooting configurable

Adds a new 'troubleshooting' function which encapsulates
the things we might want to do when something bad happens.
Typically this is echo'ing a simple message and launching a
bash shell.

The new troubleshooting function also makes use of a new
'troubleshoot' kernel param which if specific will allow you to
hang the deployment process and interactively debug the deploy_ramdisk
via a bash shell on a console.

Troubleshoot is disabled by default.

Fixes LP Bug #1191043.

Change-Id: I2cba8a9674075ba7e420027d40ef8cbe756cf07e
This commit is contained in:
Dan Prince 2013-06-14 11:39:40 -04:00
parent 207aeced03
commit 0ff82aff46
3 changed files with 12 additions and 10 deletions

View file

@ -1,7 +1,6 @@
if [ -z "$ISCSI_TARGET_IQN" ]; then if [ -z "$ISCSI_TARGET_IQN" ]; then
echo "iscsi_target_iqn is not defined" echo "iscsi_target_iqn is not defined"
echo "Starting troubleshooting shell." troubleshoot
bash
fi fi
t=0 t=0
@ -15,16 +14,14 @@ done
if [ -z "$target_disk" ]; then if [ -z "$target_disk" ]; then
echo "Could not find disk to use." echo "Could not find disk to use."
echo "Starting troubleshooting shell." troubleshoot
bash
fi fi
echo "start iSCSI target on $target_disk" echo "start iSCSI target on $target_disk"
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to start iscsi target." echo "Failed to start iscsi target."
echo "Starting troubleshooting shell." troubleshoot
bash
fi fi
echo "request boot server to deploy image" echo "request boot server to deploy image"

View file

@ -188,4 +188,10 @@ function stop_iscsi_target() {
killall tgtd killall tgtd
} }
function troubleshoot() {
if [ "$TROUBLESHOOT" == 1 ]; then
echo "Starting troubleshooting shell."
bash
fi
}

View file

@ -47,6 +47,7 @@ readonly DISK=$(get_kernel_parameter disk)
readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id) readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key) readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn) readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
readonly TROUBLESHOOT=$(get_kernel_parameter troubleshoot)
mount -t sysfs none /sys mount -t sysfs none /sys
@ -110,8 +111,7 @@ while ! BOOT_INTERFACE=$(find_interface "$BOOT_MAC_ADDRESS"); do
done done
if [ -z "$BOOT_INTERFACE" ]; then if [ -z "$BOOT_INTERFACE" ]; then
echo "could not find an interface owns MAC=$BOOT_MAC_ADDRESS" echo "could not find an interface owns MAC=$BOOT_MAC_ADDRESS"
echo "Starting troubleshooting shell." troubleshoot
bash
fi fi
readonly BOOT_INTERFACE readonly BOOT_INTERFACE
@ -123,8 +123,7 @@ if [ $? -ne 0 ]; then
ifconfig "$BOOT_INTERFACE" up ifconfig "$BOOT_INTERFACE" up
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to up $BOOT_INTERFACE" echo "Failed to up $BOOT_INTERFACE"
echo "Starting troubleshooting shell." troubleshoot
bash
fi fi
fi fi
ifconfig "$BOOT_INTERFACE" "$BOOT_IP_ADDRESS" netmask "$BOOT_NETMASK" ifconfig "$BOOT_INTERFACE" "$BOOT_IP_ADDRESS" netmask "$BOOT_NETMASK"