Commit 4824b707 authored by nanahira's avatar nanahira

fix timeout

parent 96d915b5
Pipeline #455 passed with stages
in 14 minutes and 30 seconds
...@@ -4,5 +4,10 @@ currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" ...@@ -4,5 +4,10 @@ currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
VM_ID="runner-$CUSTOM_ENV_CI_RUNNER_ID-project-$CUSTOM_ENV_CI_PROJECT_ID-concurrent-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID-job-$CUSTOM_ENV_CI_JOB_ID" VM_ID="runner-$CUSTOM_ENV_CI_RUNNER_ID-project-$CUSTOM_ENV_CI_PROJECT_ID-concurrent-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID-job-$CUSTOM_ENV_CI_JOB_ID"
_get_vm_ip() { _get_vm_ip() {
govc vm.info "-dc=$VC_DATACENTER" -json "$VM_ID" | jq .VirtualMachines[0].Guest.IpAddress | sed 's/"//g' JSON=$(govc vm.info "-dc=$VC_DATACENTER" -json "$VM_ID")
if [ $? -ne 0 ]; then
echo "fail"
else
echo "$JSON" | jq .VirtualMachines[0].Guest.IpAddress | sed 's/"//g'
fi
} }
...@@ -18,7 +18,7 @@ echo 'Waiting for VM to get IP' ...@@ -18,7 +18,7 @@ echo 'Waiting for VM to get IP'
for i in $(seq 1 30); do for i in $(seq 1 30); do
VM_IP=$(_get_vm_ip) VM_IP=$(_get_vm_ip)
if [ -n "$VM_IP" ]; then if [[ -n "$VM_IP" && "$VM_IP" -ne "fail" ]]; then
echo "VM got IP: $VM_IP" echo "VM got IP: $VM_IP"
break break
fi fi
......
...@@ -5,7 +5,22 @@ ...@@ -5,7 +5,22 @@
currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ${currentDir}/base # Get variables from base script. source ${currentDir}/base # Get variables from base script.
VM_IP=$(_get_vm_ip) for i in $(seq 1 30); do
VM_IP=$(_get_vm_ip)
if [[ -n "$VM_IP" && "$VM_IP" -ne "fail" ]]; then
break
fi
if [ "$i" == "30" ]; then
echo 'Waited 30 seconds for VM to get IP, exiting...'
# Inform GitLab Runner that this is a system failure, so it
# should be retried.
exit "$SYSTEM_FAILURE_EXIT_CODE"
fi
sleep 1s
done
ssh -T -i "${currentDir}/../ssh/id_rsa" -o StrictHostKeyChecking=no "$VC_SSH_USER@$VM_IP" "$VC_SHELL" < "${1}" ssh -T -i "${currentDir}/../ssh/id_rsa" -o StrictHostKeyChecking=no "$VC_SSH_USER@$VM_IP" "$VC_SHELL" < "${1}"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment