Add retry logic in runliveinstaller to ensure network access during pxe boot (#3257)
* update runliveinstaller * Update toolkit/resources/imageconfigs/additionalfiles/iso_initrd/root/runliveinstaller Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com> * Update toolkit/resources/imageconfigs/additionalfiles/iso_initrd/root/runliveinstaller Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com> * change to lowercase * fix typos Co-authored-by: Henry Li <lihl@microsoft.com> Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com>
This commit is contained in:
parent
8bd121791e
commit
454f40d121
|
@ -10,7 +10,6 @@ CONFIG_ROOT=$ISO_ROOT/config
|
|||
UNATTENDED_CONFIG_FILE=$CONFIG_ROOT/unattended_config.json
|
||||
|
||||
# PXE boot setup
|
||||
SERVER_CONFIG_PATH=""
|
||||
CMDLINE=/proc/cmdline
|
||||
|
||||
# parse script parameters:
|
||||
|
@ -38,6 +37,19 @@ done
|
|||
mkdir -p $ISO_ROOT
|
||||
LABEL=CDROM
|
||||
|
||||
function retry {
|
||||
local retry=0
|
||||
local limit=10
|
||||
local sleep_seconds=15
|
||||
while [ $retry -lt $limit ]
|
||||
do
|
||||
"$@" && break
|
||||
echo "$@" failed. Retrying...
|
||||
((retry++))
|
||||
sleep $sleep_seconds
|
||||
done
|
||||
}
|
||||
|
||||
if grep -qs $ISO_ROOT /proc/mounts; then
|
||||
echo ISO root already mounted
|
||||
# Read from /proc/cmdline to get image configs from PXE server
|
||||
|
@ -46,6 +58,12 @@ elif grep -q "image-config" $CMDLINE; then
|
|||
# $IMAGE_CONFIG_VALUE will be in this fixed format: http://PXE_SERVER_IP/RANDOM_PATH
|
||||
# CUT_DIRS will be an array of strings separated by '/'
|
||||
IFS='/' read -ra CUT_DIRS <<< $IMAGE_CONFIG_VALUE
|
||||
|
||||
# It is possible that the installation environment does not have network access yet when
|
||||
# this script is first run. So use a retry loop
|
||||
PXE_SERVER_IP=$(echo "$IMAGE_CONFIG_VALUE" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
|
||||
retry ping -c 1 $PXE_SERVER_IP
|
||||
|
||||
# To disable generation of any extra directories and just download the contents within the directory,
|
||||
# use -nH to disable genration of host-prefix, "PXE_SERVER_IP".
|
||||
# To disable generation of "RANDOM_PATH", set --cut-dirs to the number of strings separated by '/'.
|
||||
|
@ -58,16 +76,7 @@ else
|
|||
echo Attempt to mount the ISO root
|
||||
# It is possible that the partition isn't ready to be mounted when this script
|
||||
# is first run. So use a retry loop.
|
||||
RETRY=0
|
||||
LIMIT=5
|
||||
SLEEPSECONDS=2
|
||||
while [ $RETRY -lt $LIMIT ]
|
||||
do
|
||||
mount -L $LABEL -o ro $ISO_ROOT && break
|
||||
echo Mount failed. Retrying...
|
||||
((RETRY++))
|
||||
sleep $SLEEPSECONDS
|
||||
done
|
||||
retry mount -L $LABEL -o ro $ISO_ROOT
|
||||
fi
|
||||
|
||||
if [[ ! -f "$UNATTENDED_CONFIG_FILE" ]]; then
|
||||
|
|
Loading…
Reference in New Issue