2 # shellcheck disable=SC2016,SC2046
4 #SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
7 # Execute in a subshell to prevent local variable override during recursion
9 local total_attempts=$1; shift
12 echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}"
13 # shellcheck disable=SC2034
14 for attempt in $(seq "${total_attempts}"); do
15 echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
16 # shellcheck disable=SC2015
17 eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
20 echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"
26 kubectl create -f configMap.yaml
27 wait_for 5 'test $(kubectl get configmap -n kube-system | grep sriovdp-config -c ) -eq 1'
29 kubectl create -f multus-sriov-flannel-daemonsets.yaml
30 wait_for 100 'test $(kubectl get pods -n kube-system | grep -e "kube-multus-ds" | grep "Running" -c) -ge 1'
31 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "kube-sriov-cni" | grep "Running" -c) -ge 1'
32 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "kube-sriov-device-plugin" | grep "Running" -c) -ge 1'
34 kubectl create -f flannel-daemonset.yml
35 wait_for 100 'test $(kubectl get pods -n kube-system | grep -e "kube-flannel-ds" | grep "Running" -c) -ge 1'
37 kubectl create -f sriov-crd.yaml
38 wait_for 5 'test $(kubectl get crd | grep -e "network-attachment-definitions" -c) -ge 1'
41 kubectl get node $(hostname) -o json | jq '.status.allocatable'