Skip to content

Commit

Permalink
Fix shell redirect, cleanup (istio#11253)
Browse files Browse the repository at this point in the history
  • Loading branch information
ostromart authored and hklai committed Jan 25, 2019
1 parent efef2f1 commit f1eab0a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/upgrade/test_crossgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ ISTIO_ROOT=${GOPATH}/src/istio.io/istio
TMP_DIR=/tmp/istio_upgrade_test
LOCAL_FORTIO_LOG=${TMP_DIR}/fortio_local.log
POD_FORTIO_LOG=${TMP_DIR}/fortio_pod.log
ERROR_TMP_LOG=${TMP_DIR}/error_temp.log

# Make sure to change templates/*.yaml with the correct address if this changes.
TEST_NAMESPACE="test"
Expand All @@ -130,14 +129,13 @@ withRetries() {
shift
shift
while (( n < max_retries )); do
echo "RUNNING $*" ; "${@}" > "${ERROR_TMP_LOG}" 2>&1 && break
echo "RUNNING $*" ; "${@}" && break
echo "Failed, sleeping ${sleep_sec} seconds and retrying..."
cat "${ERROR_TMP_LOG}"
((n++))
sleep "${sleep_sec}"
done

if (( n == max_retries )); then cat "${ERROR_TMP_LOG}"; die "$* failed after retrying ${max_retries} times."; fi
if (( n == max_retries )); then die "$* failed after retrying ${max_retries} times."; fi
echo "Succeeded."
}

Expand All @@ -151,13 +149,12 @@ withRetriesMaxTime() {
shift
shift
while (( SECONDS - start_time < total_time_max )); do
echo "RUNNING $*" ; "${@}" > "${ERROR_TMP_LOG}" 2>&1 && break
echo "RUNNING $*" ; "${@}" && break
echo "Failed, sleeping ${sleep_sec} seconds and retrying..."
cat "${ERROR_TMP_LOG}"
sleep "${sleep_sec}"
done

if (( SECONDS - start_time >= total_time_max )); then cat "${ERROR_TMP_LOG}"; die "$* failed after retrying for ${total_time_max} seconds."; fi
if (( SECONDS - start_time >= total_time_max )); then die "$* failed after retrying for ${total_time_max} seconds."; fi
echo "Succeeded."
}

Expand All @@ -174,14 +171,15 @@ checkIfDeleted() {
if [[ "${resp}" == *"Error from server (NotFound)"* ]]; then
return 0
fi
echo "Response from server for kubectl get: ${resp}"
echo "Response from server for kubectl get: "
echo "${resp}"
return 1
}

deleteWithWait() {
# Don't complain if resource is already deleted.
echo_and_run_quiet kubectl delete "${1}" -n "${3}" "${2}"
withRetries 10 60 checkIfDeleted "${1}" "${2}" "${3}"
withRetries 60 10 checkIfDeleted "${1}" "${2}" "${3}"
}

installIstioSystemAtVersionHelmTemplate() {
Expand Down Expand Up @@ -209,7 +207,7 @@ installIstioSystemAtVersionHelmTemplate() {
--set global.hub="${1}" \
--set global.tag="${2}" > "${ISTIO_ROOT}/istio.yaml" || die "helm template failed"

withRetries 10 60 kubectl apply -f "${ISTIO_ROOT}"/istio.yaml
withRetries 3 60 kubectl apply -f "${ISTIO_ROOT}"/istio.yaml
}

installTest() {
Expand Down

0 comments on commit f1eab0a

Please sign in to comment.