mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 22:51:03 +02:00
Robustify starting of ssh connection to vm updater.
Change-Id: Ia5e0042250da22cebadfd48d143f21597bcada5d BUG=chromium-os:11716 TEST=Ran vm test and vm update scripts. Review URL: http://codereview.chromium.org/6413019
This commit is contained in:
parent
93da99be03
commit
99768e8e12
@ -31,8 +31,6 @@ find_common_sh
|
||||
. "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || \
|
||||
die "Unable to load cros_vm_constants.sh"
|
||||
|
||||
MAX_RETRIES=3
|
||||
|
||||
get_default_board
|
||||
|
||||
DEFINE_string board "$DEFAULT_BOARD" \
|
||||
@ -88,8 +86,7 @@ done
|
||||
|
||||
trap stop_kvm EXIT
|
||||
start_kvm "${FLAGS_image_path}"
|
||||
info "Checking for ssh access to virtual machine."
|
||||
retry_until_ssh ${MAX_RETRIES}
|
||||
retry_until_ssh
|
||||
|
||||
if [ -n "${FLAGS_verify_chrome_version}" ]; then
|
||||
info "Verifying version of Chrome matches what we expect."
|
||||
|
@ -50,6 +50,7 @@ eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
trap stop_kvm EXIT
|
||||
start_kvm "${FLAGS_vm_image_path}"
|
||||
retry_until_ssh
|
||||
|
||||
if [ -n "${FLAGS_update_image_path}" ]; then
|
||||
IMAGE_ARGS="--image=$(readlink -f ${FLAGS_update_image_path})"
|
||||
|
@ -100,10 +100,11 @@ function ssh_ping() {
|
||||
# shutting down and restarting kvm.
|
||||
function retry_until_ssh() {
|
||||
local can_ssh_into=1
|
||||
local max_retries=3
|
||||
local retries=0
|
||||
ssh_ping && can_ssh_into=0
|
||||
|
||||
while [ ${can_ssh_into} -eq 1 ] && [ ${retries} -lt ${1} ]; do
|
||||
while [ ${can_ssh_into} -eq 1 ] && [ ${retries} -lt ${max_retries} ]; do
|
||||
echo "Failed to connect to virtual machine, retrying ... " >&2
|
||||
stop_kvm || echo "Could not stop kvm. Retrying anyway." >&2
|
||||
start_kvm "${LIVE_VM_IMAGE}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user