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}"
24 kubectl create -f configMap.yaml
25 wait_for 5 'test $(kubectl get configmap -n kube-system | grep sriovdp-config -c ) -eq 1'
27 kubectl create -f multus-sriov-calico-daemonsets.yaml
28 wait_for 100 'test $(kubectl get pods -n kube-system | grep -e "kube-multus-ds" | grep "Running" -c) -ge 1'
29 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "kube-sriov-cni" | 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'
31 #kubectl create -f multus-sriov-calico-daemonsets-k8s-v1.16.yaml
33 kubectl create -f calico-daemonset.yaml
34 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "calico-kube-controllers" | grep "Running" -c) -ge 1'
35 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "calico-node" | grep "Running" -c) -ge 1'
36 #kubectl create -f calico-daemonset-k8s-v1.16.yml
38 kubectl create -f sriov-crd.yaml
39 wait_for 5 'test $(kubectl get crd | grep -e "network-attachment-definitions" -c) -ge 1'
42 kubectl get node $(hostname) -o json | jq '.status.allocatable' || true
43 kubectl get pods --all-namespaces