mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-03-27 03:13:10 +00:00
This changes the runme.sh of the kubevirt_vm integration tests to retry the connection to the VM until a login is possible. This is necessary since it is not possible with Ansible alone to retry a task in case the connection failed with the unreachable status. This can happen when the sshd of the VM already accepts connections but a login is not yet possible because the VM is still booting up. Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
31 lines
979 B
Bash
Executable File
31 lines
979 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eux
|
|
set -o pipefail
|
|
|
|
export ANSIBLE_CALLBACKS_ENABLED=ansible.posix.profile_tasks
|
|
export ANSIBLE_INVENTORY_ENABLED=kubevirt.core.kubevirt
|
|
export ANSIBLE_HOST_KEY_CHECKING=False
|
|
|
|
[ -d files ] || mkdir files
|
|
[ -f files/testkey ] || (ssh-keygen -t ed25519 -C test@test -f files/testkey -N "")
|
|
|
|
ansible-playbook playbook.yml "$@"
|
|
|
|
ansible-inventory -i test.kubevirt.yml -y --list "$@"
|
|
|
|
# Retry connection to VM until a login is possible
|
|
# This is necessary since wait_for is not enough to wait for logins to be possible.
|
|
# wait_for is only able to wait until sshd accepts connections.
|
|
retries=0
|
|
while ! ansible-playbook wait_for_vm.yml -i test.kubevirt.yml --private-key=files/testkey "$@"; do
|
|
if [ "$retries" -ge "10" ]; then
|
|
echo "Maximum retries reached, giving up"
|
|
exit 1
|
|
fi
|
|
echo "Failed to wait for VM, retrying..."
|
|
sleep 10
|
|
((retries+=1))
|
|
done
|
|
|
|
ansible-playbook verify.yml --diff -i test.kubevirt.yml --private-key=files/testkey "$@"
|