Skip to content

Commit

Permalink
e2e: fix kubectl_retry to not return a stale error
Browse files Browse the repository at this point in the history
While deploying Rook, there can be issues when the environment is not
completely settled yet. On occasion the 1st kubectl command fails with

    The connection to the server ... was refused - did you specify the right host or port?

This would set the 'ret' variable to a non-zero value, before the next
retry of the kubectl command is done. In case the kubectl command
succeeds, the 'ret' variable still contains the old non-zero value, and
kubectl_retry returns the incorrect result.

By setting the 'ret' variable to 0 before calling kubectl again, this
problem is prevented.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
  • Loading branch information
nixpanic authored and mergify[bot] committed Dec 9, 2020
1 parent 9160a53 commit 09fac4d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/rook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ kubectl_retry() {
echo "kubectl_retry ${*} failed, will retry in ${KUBECTL_RETRY_DELAY} seconds"

sleep ${KUBECTL_RETRY_DELAY}

# reset ret so that a next working kubectl does not cause a non-zero
# return of the function
ret=0
done

# write output so that calling functions can consume it
Expand Down

0 comments on commit 09fac4d

Please sign in to comment.