2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-09 05:00:44 +00:00
Files
xcat-core/xCAT-test/autotest/testcase/commoncmd/retry_install.sh
T
Daniel Hilst a6f77a9732 fix(xcat-core): complete the Ubuntu Subiquity diskful install
Boot the live installer correctly. Add boot=casper so casper actually processes
netboot=nfs instead of scanning local disks and panicking, resolve the install server
to a literal IP because casper mounts the live filesystem with klibc's nfsmount which
has no resolver, and add toram so casper copies the squashfs into RAM and unmounts the
NFS source. That last one is what lets the node reboot at all: with the NFS root still
mounted, systemd-shutdown waits forever on an lvm/pvscan wedged in uninterruptible I/O
on it and the node never power-cycles into the disk it just installed. casper has no
cmdline knob for NFS mount options -- it parses only nfsroot= and takes the whole value
as the path -- so toram is its supported way to avoid a network root.

Write the installer's resolv.conf nameserver as an IP. glibc's resolver discards a
hostname given on a nameserver line, so the xcatmaster name left the installer, and
the in-target apt that inherits the file, with no DNS at all.

Add the online archive through apt `sources:` on classic-sources releases, where
Subiquity renders the target sources.list from the install media alone and in-target
apt cannot find packages the ISO does not carry. Deb822 releases are excluded: their
primary mirror already lands in ubuntu.sources, so legacy .list files would configure
the same suites twice.

Flip the node to local-disk boot from the live installer over bash's /dev/tcp instead
of relying on updateflag.awk, which needs gawk's |& coprocess while Ubuntu's
/usr/bin/awk is mawk. The exchange is checked, and a failure is recorded in the
install log rather than silently PXE-looping into another install.

Defer syncfiles to the postbootscripts on the diskful install path, so it runs on the
booted node with sshd up rather than inside the in-target chroot where the MN cannot
reach it.

Make the test harness's provision wait overridable through WAIT_FOR_PROVISION; the
default stays short so a boot loop still fails fast.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-08-24 15:41:32 -03:00

90 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
declare -i installsuccess=0
declare -i a=0
declare -i tryreinstall=1
node=$1
osimage=$2
vmhost=`lsdef $node -i vmhost -c | cut -d '=' -f 2`
times=2
wait_for_provision=${WAIT_FOR_PROVISION:-20} #Min to wait for node to provision (overridable via WAIT_FOR_PROVISION; kept short so a boot-loop fails fast, raised only where the happy path is slow -- e.g. Ubuntu subiquity diskful)
check_status=10 #Sec to keep checking status
iterations=$wait_for_provision*60/$check_status #Iterations to check for "booted" status
if [ $# -eq 3 ];
then
times=$3
fi
echo "Try to rinstall for $times times (allowing $wait_for_provision min for each try) ......"
for (( tryreinstall = 1 ; tryreinstall <= $times ; ++tryreinstall ))
do
echo "[$tryreinstall] Trying to install $node with $osimage ..."
if [[ ! -z $vmhost ]];then
# Display memory and active VMs on VM host, when installing on VM
echo "Memory on vmhost $vmhost"
ssh $vmhost free -m
echo "Active VMs on vmhost $vmhost"
ssh $vmhost virsh list
fi
echo "rinstall $node osimage=$osimage"
rinstall $node osimage=$osimage
if [ $? != 0 ];then
echo "First attempt to run rinstall command failed ..."
# First rinstall failed, try again with verbose flag
rinstall $node osimage=$osimage -V
if [ $? != 0 ];then
echo "Second attempt to run rinstall command failed ..."
exit 1
fi
fi
#sleep while for installation.
sleep 360
while [ ! `lsdef -l $node|grep status|grep booted` ]
do
sleep $check_status
stat=`lsdef $node -i status -c | cut -d '=' -f 2`
echo "[$a] The status is not booted... ($stat)"
if [ $stat = "failed" ]; then
# Installation failed, no reason to keep checking
break
fi
a=++a
if [ $a -gt $(($iterations + 0)) ];then
a=0
break
fi
done
lsdef -l $node|grep status|grep booted
tobooted=$?
echo "The tobooted is $tobooted"
ping -c 2 $node
pingable=$?
echo "The pingable is $pingable"
xdsh $node date
canruncmd=$?
echo "The canruncmd is $canruncmd"
if [[ $canruncmd -eq 0 && $tobooted -eq 0 && $pingable -eq 0 ]];then
echo "The provision succeeded on the $tryreinstall time....."
installsuccess=1
break
fi
done
if [ $installsuccess -eq 1 ];then
echo "The provision succeeded......"
exit 0
else
echo "The provision failed......"
exit 1
fi