[Build] Fix the build unstalbe issue caused by the kvm not ready (#12180)
Why I did it Fix the build unstable issue caused by the kvm 9000 port is not ready to use in 2 seconds. 2022-09-02T10:57:30.8122304Z + /usr/bin/kvm -m 8192 -name onie -boot order=cd,once=d -cdrom target/files/bullseye/onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso -device e1000,netdev=onienet -netdev user,id=onienet,hostfwd=:0.0.0.0:3041-:22 -vnc 0.0.0.0:0 -vga std -drive file=target/sonic-6asic-vs.img,media=disk,if=virtio,index=0 -drive file=./sonic-installer.img,if=virtio,index=1 -serial telnet:127.0.0.1:9000,server 2022-09-02T10:57:30.8123378Z + sleep 2.0 2022-09-02T10:57:30.8123889Z + '[' -d /proc/284923 ']' 2022-09-02T10:57:30.8124528Z + echo 'to kill kvm: sudo kill 284923' 2022-09-02T10:57:30.8124994Z to kill kvm: sudo kill 284923 2022-09-02T10:57:30.8125362Z + ./install_sonic.py 2022-09-02T10:57:30.8125720Z Trying 127.0.0.1... 2022-09-02T10:57:30.8126041Z telnet: Unable to connect to remote host: Connection refused How I did it Waiting more time until the tcp port 9000 is ready, waiting for 60 seconds in maximum.
This commit is contained in:
parent
1b50a2b721
commit
60c80ad26d
@ -49,6 +49,19 @@ prepare_installer_disk()
|
|||||||
umount $tmpdir
|
umount $tmpdir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_kvm_ready()
|
||||||
|
{
|
||||||
|
local count=30
|
||||||
|
local waiting_in_seconds=2.0
|
||||||
|
for ((i=1; i<=$count; i++)); do
|
||||||
|
sleep $waiting_in_seconds
|
||||||
|
echo "$(date) [$i/$count] waiting for the port $KVM_PORT ready"
|
||||||
|
if netstat -l | grep -q ":$KVM_PORT"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
apt-get install -y net-tools
|
apt-get install -y net-tools
|
||||||
create_disk
|
create_disk
|
||||||
prepare_installer_disk
|
prepare_installer_disk
|
||||||
@ -86,7 +99,7 @@ echo "Installing SONiC"
|
|||||||
|
|
||||||
kvm_pid=$!
|
kvm_pid=$!
|
||||||
|
|
||||||
sleep 2.0
|
wait_kvm_ready
|
||||||
|
|
||||||
[ -d "/proc/$kvm_pid" ] || {
|
[ -d "/proc/$kvm_pid" ] || {
|
||||||
echo "ERROR: kvm died."
|
echo "ERROR: kvm died."
|
||||||
@ -114,7 +127,7 @@ echo "Booting up SONiC"
|
|||||||
|
|
||||||
kvm_pid=$!
|
kvm_pid=$!
|
||||||
|
|
||||||
sleep 2.0
|
wait_kvm_ready
|
||||||
|
|
||||||
[ -d "/proc/$kvm_pid" ] || {
|
[ -d "/proc/$kvm_pid" ] || {
|
||||||
echo "ERROR: kvm died."
|
echo "ERROR: kvm died."
|
||||||
|
Loading…
Reference in New Issue
Block a user