Browse Source

Make hard-coded busybox image configurable

The image used to test kubectl logs in the validation scripts was hard
coded and is now configurable.

This also makes the power-up-node.sh gate script more robust by making
it wait for the node to be ready.

Change-Id: I531ca8477ac3575dd4249ab5e991881af290fa52
Mark Burnett 10 months ago
parent
commit
44fb6db261

+ 3
- 0
examples/basic/HostSystem.yaml View File

@@ -75,4 +75,7 @@ data:
75 75
     required:
76 76
       docker: docker-engine=1.13.1-0~ubuntu-xenial
77 77
       socat: socat=1.7.3.1-1
78
+  validation:
79
+    pod_logs:
80
+      image: busybox:1.28.3
78 81
 ...

+ 11
- 0
promenade/schemas/HostSystem.yaml View File

@@ -131,6 +131,17 @@ data:
131 131
         - required
132 132
       additionalProperties: false
133 133
 
134
+    validation:
135
+      type: object
136
+      properties:
137
+        pod_logs:
138
+          type: object
139
+          properties:
140
+            image:
141
+              type: string
142
+          additionalProperties: false
143
+      additionalProperties: false
144
+
134 145
   required:
135 146
     - images
136 147
     - packages

+ 1
- 1
promenade/templates/include/utils.sh View File

@@ -234,7 +234,7 @@ spec:
234 234
     kubernetes.io/hostname: ${NODE}
235 235
   containers:
236 236
   - name: noisy
237
-    image: busybox:1.28.3
237
+    image: {{ config.get_path('HostSystem:validation.pod_logs.image', default='busybox:1.28.3') }}
238 238
     imagePullPolicy: IfNotPresent
239 239
     command:
240 240
     - /bin/echo

+ 30
- 0
tools/g2/lib/kube.sh View File

@@ -42,3 +42,33 @@ kubectl_wait_for_pod() {
42 42
         fi
43 43
     done
44 44
 }
45
+
46
+kubectl_wait_for_node_ready() {
47
+    set +x
48
+
49
+    VIA=${1}
50
+    NODE_NAME=${2}
51
+    SEC=${3:-300}
52
+
53
+    log Waiting $SEC seconds for $NODE_NAME to be ready.
54
+
55
+    NODE_READY_JSONPATH='{.status.conditions[?(@.type=="Ready")].status}'
56
+
57
+    end=$(($(date +%s) + $SEC))
58
+    while true; do
59
+        if (kubectl_cmd "${VIA}" --request-timeout 10s get nodes $NODE_NAME -o jsonpath="${NODE_READY_JSONPATH}" | grep True) ; then
60
+            log Node $NODE_NAME is ready.
61
+            break
62
+        else
63
+            now=$(date +%s)
64
+            if [ $now -gt $end ]; then
65
+                log Node $NODE_NAME was not ready before timeout.
66
+                fail
67
+            fi
68
+            echo -n .
69
+            sleep 15
70
+        fi
71
+    done
72
+
73
+    set -x
74
+}

+ 3
- 1
tools/g2/manifests/resiliency.json View File

@@ -102,7 +102,9 @@
102 102
       "name": "Power up n2",
103 103
       "script": "power-up-node.sh",
104 104
       "arguments": [
105
-        "-n", "n2"
105
+        "-v", "n0",
106
+        "-n", "n2",
107
+        "-w", "120"
106 108
       ]
107 109
     },
108 110
     {

+ 13
- 1
tools/g2/stages/power-up-node.sh View File

@@ -6,11 +6,19 @@ source "${GATE_UTILS}"
6 6
 
7 7
 declare -a NODES
8 8
 
9
-while getopts "n:s" opt; do
9
+WAIT=60
10
+
11
+while getopts "n:v:w:s" opt; do
10 12
     case "${opt}" in
11 13
         n)
12 14
             NODES+=("${OPTARG}")
13 15
             ;;
16
+        v)
17
+            VIA="${OPTARG}"
18
+            ;;
19
+        w)
20
+            WAIT="${OPTARG}"
21
+            ;;
14 22
         *)
15 23
             echo "Unknown option"
16 24
             exit 1
@@ -22,3 +30,7 @@ shift $((OPTIND-1))
22 30
 for node in "${NODES[@]}"; do
23 31
     vm_start "${node}"
24 32
 done
33
+
34
+for node in "${NODES[@]}"; do
35
+    kubectl_wait_for_node_ready "${VIA}" "${node}" "${WAIT}"
36
+done

Loading…
Cancel
Save