Skip to content

Commit

Permalink
CI: cni wait
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 committed Nov 9, 2023
1 parent eb6a2ee commit d2af406
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
9 changes: 3 additions & 6 deletions test/e2e/pipeline/infra/cluster-api/cni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ EOF

function wait_calico() {
local kubeconfig=$1
sleep 5
"${KUBECTL}" wait --for condition=Ready=true -n calico-system pod --all --kubeconfig "$kubeconfig" --timeout=-1s
sleep 10
waitandretry 5s 12 "${KUBECTL} wait --for condition=Ready=true -n calico-system pod --all --kubeconfig $kubeconfig --timeout=-1s"
# set felix to use different port for VXLAN
"${KUBECTL}" patch felixconfiguration default --type='merge' -p '{"spec":{"vxlanPort": 6789}}' --kubeconfig "$kubeconfig"
waitandretry 5s 12 "${KUBECTL} patch felixconfiguration default --type='merge' -p '{\"spec\":{\"vxlanPort\": 6789}}' --kubeconfig $kubeconfig"
}

function install_cilium() {
Expand Down Expand Up @@ -115,6 +113,5 @@ function install_flannel() {

function wait_flannel() {
local kubeconfig=$1
sleep 15
"${KUBECTL}" wait --for condition=Ready=true -n kube-flannel pod --all --timeout=-1s --kubeconfig "$kubeconfig"
waitandretry 5s 12 "${KUBECTL} wait --for condition=Ready=true -n kube-flannel pod --all --timeout=-1s --kubeconfig $kubeconfig"
}
15 changes: 10 additions & 5 deletions test/e2e/pipeline/utils.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
#shellcheck disable=SC1091

# Define the retry function
retry() {
local retries="$1"
local command="$2"
waitandretry() {
local waittime="$1"
local retries="$2"
local command="$3"
local options="$-" # Get the current "set" options

sleep "${waittime}"

echo "Running command: ${command} (retries left: ${retries})"

# Disable set -e
if [[ $options == *e* ]]; then
set +e
Expand All @@ -24,9 +29,9 @@ retry() {
# If the exit code is non-zero (i.e. command failed), and we have not
# reached the maximum number of retries, run the command again
if [[ $exit_code -ne 0 && $retries -gt 0 ]]; then
retry $(($retries - 1)) "$command"
waitandretry "$waittime" $((retries - 1)) "$command"
else
# Return the exit code from the command
return $exit_code
fi
}
}

0 comments on commit d2af406

Please sign in to comment.