Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable retry of ibmcloud login command to avoid timeout failure #1357

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cd "${REPO_ROOT}" || exit 1
GOPATH_BIN="$(go env GOPATH)/bin/"
export PATH="${GOPATH_BIN}:${PATH}"
RESOURCE_TYPE="${RESOURCE_TYPE:-"powervs-service"}"
NO_OF_RETRY=${NO_OF_RETRY:-"3"}

# shellcheck source=../hack/ensure-go.sh
source "${REPO_ROOT}/hack/ensure-go.sh"
Expand Down Expand Up @@ -52,6 +53,23 @@ cleanup(){
[[ -z ${HEART_BEAT_PID:-} ]] || kill -9 "${HEART_BEAT_PID}" || true
}

retry() {
cmd=$1
for i in $(seq 1 "$NO_OF_RETRY"); do
echo "Attempt: $i/$NO_OF_RETRY"
ret_code=0
$cmd || ret_code=$?
if [ $ret_code = 0 ]; then
break
elif [ "$i" == "$NO_OF_RETRY" ]; then
echo "All retry attempts failed!"
exit $ret_code
else
sleep 1
fi
done
}

install_ibmcloud_cli(){
if [ ${OS} == "Linux" ]; then
platform="linux_${ARCH}"
Expand All @@ -70,7 +88,7 @@ create_powervs_network_instance(){

ibmcloud config --check-version=false
# Login to IBM Cloud using the API Key
ibmcloud login -a cloud.ibm.com -r ${REGION}
retry "ibmcloud login -a cloud.ibm.com -r ${REGION}"

# Install power-iaas command-line plug-in and target the required service instance
ibmcloud plugin install power-iaas -f
Expand Down