@@ -4,22 +4,40 @@ set -o nounset
4
4
set -o pipefail
5
5
set -o xtrace
6
6
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
8
30
# Pre-pull all the test images. The images are currently hard-coded.
9
31
# Eventually, we should get the list directly from
10
32
# https://github.com/kubernetes-sigs/windows-testing/blob/master/images/PullImages.ps1
11
33
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 }
14
36
fi
15
37
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
20
40
# Check the status of the pods.
21
41
kubectl get pods -o wide
22
42
# 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