@@ -4,22 +4,40 @@ set -o nounset
44set -o pipefail
55set -o xtrace
66
7- if [[ -z " ${PREPULL_IMAGE} " ]]; then
7+ # This is taken from prepull.yaml.
8+ readonly prepull_daemonset=prepull-test-containers
9+
10+ wait_on_prepull ()
11+ {
12+ # Wait up to 15 minutes for the test images to be pulled onto the nodes.
13+ retries=90
14+ while [[ $retries -ge 0 ]]; do
15+ ready=$( kubectl get daemonset " ${prepull_daemonset} " -o jsonpath=" {.status.numberReady}" )
16+ required=$( kubectl get daemonset " ${prepull_daemonset} " -o jsonpath=" {.status.desiredNumberScheduled}" )
17+ if [[ $ready -eq $required ]]; then
18+ echo " Daemonset $prepull_daemonset ready"
19+ return 0
20+ fi
21+ (( retries-- ))
22+ sleep 10s
23+ done
24+ echo " Timeout waiting for daemonset $prepull_daemonset "
25+ return -1
26+
27+ }
28+
29+ if [[ -z " ${PREPULL_YAML} " ]]; then
830 # Pre-pull all the test images. The images are currently hard-coded.
931 # Eventually, we should get the list directly from
1032 # https://github.com/kubernetes-sigs/windows-testing/blob/master/images/PullImages.ps1
1133 curl https://raw.githubusercontent.com/kubernetes-sigs/windows-testing/master/gce/prepull-1.18.yaml -o prepull.yaml
12- PREPULL_IMAGE =prepull.yaml
13- echo ${PREPULL_IMAGE }
34+ PREPULL_YAML =prepull.yaml
35+ echo ${PREPULL_YAML }
1436fi
1537
16- kubectl create -f ${PREPULL_IMAGE}
17- # Wait 10 minutes for the test images to be pulled onto the nodes.
18- sleep 15m
19- echo " sleep 15m"
38+ kubectl create -f ${PREPULL_YAML}
39+ wait_on_prepull || exit -1 # Error already printed
2040# Check the status of the pods.
2141kubectl get pods -o wide
2242# Delete the pods anyway since pre-pulling is best-effort
23- kubectl delete -f ${PREPULL_IMAGE}
24- # Wait a few more minutes for the pod to be cleaned up.
25- sleep 5m
43+ kubectl delete -f ${PREPULL_YAML} --wait=true
0 commit comments