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