From 2f7fb80498605c91b78306e2acd9ca64f01a3dac Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 20 Apr 2022 16:22:28 +0200 Subject: [PATCH] ci: improve logging for `kubectl_retry` helper Rook deployments fail quite regulary in the CI environment now. It is not clear what the cause is, hopefully a little better logging will guide us to the issue. Now executing `kubectl` in a sub-shell, ensuring that the redirection of the command lands in the right files. Signed-off-by: Niels de Vos (cherry picked from commit 1e21972956e903763d2dea45ac02482c277285c0) --- scripts/utils.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/utils.sh b/scripts/utils.sh index a7605b7c3..3c215e8b2 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -11,7 +11,7 @@ kubectl_retry() { stdout=$(mktemp rook-kubectl-stdout.XXXXXXXX) stderr=$(mktemp rook-kubectl-stderr.XXXXXXXX) - while ! kubectl "${action}" "${@}" 2>"${stderr}" 1>"${stdout}" + while ! ( kubectl "${action}" "${@}" 2>"${stderr}" 1>"${stdout}" ) do # in case of a failure when running "create", ignore errors with "AlreadyExists" if [ "${action}" == 'create' ] @@ -47,7 +47,7 @@ kubectl_retry() { # log stderr and empty the tmpfile cat "${stderr}" > /dev/stderr true > "${stderr}" - echo "kubectl_retry ${*} failed, will retry in ${KUBECTL_RETRY_DELAY} seconds" + echo "$(date): 'kubectl_retry ${*}' failed (${retries}/${KUBECTL_RETRY}), will retry in ${KUBECTL_RETRY_DELAY} seconds" > /dev/stderr sleep ${KUBECTL_RETRY_DELAY} @@ -56,6 +56,8 @@ kubectl_retry() { ret=0 done + echo "$(date): 'kubectl_retry ${*}' done (ret=${ret})" > /dev/stderr + # write output so that calling functions can consume it cat "${stdout}" > /dev/stdout cat "${stderr}" > /dev/stderr