Skip to content

Commit 6c89440

Browse files
committed
ref(smoketest): break out lengthy script; also remove containerdruntimeoptions if k3d
Signed-off-by: Vaughn Dice <vdice@akamai.com>
1 parent 896fe21 commit 6c89440

3 files changed

Lines changed: 51 additions & 44 deletions

File tree

.github/workflows/helm-chart-smoketest.yml

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -156,58 +156,26 @@ jobs:
156156
--set rcm.shimDownloaderConfig.content.sleepDuration=3 \
157157
deploy/helm
158158
159-
- name: verify configMap for shim-downloader is added
160-
run: |
161-
timeout 60s bash -c 'until [[ $(kubectl -n rcm get $(kubectl get pods -n rcm --no-headers -o name | grep install | head -n1) -o jsonpath="{.spec.initContainers[0].envFrom[0].configMapRef.name}" 2>/dev/null) == "configmap-test" ]]; do sleep 2; done'
162-
163159
- name: apply shims
164160
run: |
165161
for shim_file in $(ls config/samples/sample_shim*); do
166-
if [[ "${{ matrix.config.type }}" == "microk8s" ]]; then
167-
cp $shim_file $shim_file.microk8s
168-
shim_file=$shim_file.microk8s
162+
if [[ "${{ matrix.config.type }}" == "microk8s" || "${{ matrix.config.type }}" == "k3d" ]]; then
163+
cp $shim_file $shim_file.amended
164+
shim_file=$shim_file.amended
169165
# update file to remove the 'containerdRuntimeOptions' field
170166
# as there is a known bug that MicroK8s containerd does not pass the options
167+
# and k3d uses cgroupfs, not systemd
171168
yq -i 'del(.spec.containerdRuntimeOptions)' $shim_file
172169
fi
173170
kubectl apply -f $shim_file
174171
done
175172
176-
- name: label nodes and wait for shim to be ready
177-
run: |
178-
for shim_file in $(ls config/samples/sample_shim*); do
179-
label="$(cat $shim_file | yq '.spec.nodeSelector' | tr -d '"' | tr -d '[:space:]' | sed s/:/=/g)"
180-
kubectl label node --all $label
181-
182-
shim_name="$(cat $shim_file | yq '.metadata.name')"
183-
# TODO: k3d can take a long round of failed install pods (exit code 6 when curling the artifact?)
184-
# Once this behavior is diagnosed and resolved, we should be able to shorten this timeout substantially
185-
timeout=600
186-
SECONDS=0 # Reset the internal bash timer to 0
187-
success=false
188-
189-
echo "Waiting for the $shim_name shim to be ready/installed..."
190-
191-
while [[ $SECONDS -lt $timeout ]]; do
192-
# Fetch both nodes and nodesReady
193-
read -r nodes nodesReady <<< $(kubectl get shim "$shim_name" \
194-
-o jsonpath='{.status.nodes} {.status.nodesReady}' 2>/dev/null)
195-
196-
# Check to see if all nodes are ready
197-
if [[ -n "$nodes" ]] && [[ -n "$nodesReady" ]] && [[ "$nodes" -eq "$nodesReady" ]]; then
198-
echo "Success: all nodes have the $shim_name shim installed."
199-
success=true
200-
break
201-
fi
202-
203-
sleep 2
204-
done
173+
- name: label nodes and wait for shims to be ready
174+
run: ./scripts/sample-shims-label-nodes.sh
205175

206-
if [[ "${success}" != "true" ]]; then
207-
echo "Error: Timed out after ${timeout}s waiting for the $shim_name shim to be ready."
208-
exit 1
209-
fi
210-
done
176+
- name: verify configMap for shim-downloader is added
177+
run: |
178+
timeout 60s bash -c 'until [[ $(kubectl -n rcm get $(kubectl get pods -n rcm --no-headers -o name | grep install | head -n1) -o jsonpath="{.spec.initContainers[0].envFrom[0].configMapRef.name}" 2>/dev/null) == "configmap-test" ]]; do sleep 2; done'
211179
212180
# TODO: unify testdata/apps to all model the same behavor, eg simple web server, etc
213181
- name: run and verify spin app
@@ -228,14 +196,14 @@ jobs:
228196
if: failure()
229197
run: |
230198
kubectl get pods -A
231-
kubectl describe shims
232-
kubectl describe runtimeclasses
199+
kubectl describe shims || true
200+
kubectl describe runtimeclasses || true
233201
234202
# Get install pod logs
235203
# Note: there may be multiple pods pending k3d fix for issue https://github.com/spinframework/runtime-class-manager/issues/393
236204
for shim_file in $(ls config/samples/sample_shim*); do
237205
shim_name="$(cat $shim_file | yq '.metadata.name')"
238-
install_pods="$(kubectl get pods -n rcm --no-headers -o name | grep $shim_name-install)"
206+
install_pods="$(kubectl get pods -n rcm --no-headers -o name | grep $shim_name-install || true)"
239207
for pod in $install_pods; do
240208
kubectl describe -n rcm $pod || true
241209
kubectl logs -n rcm -c downloader $pod || true

scripts/sample-shims-apply.sh

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Currently used in .github/workflows/helm-chart-smoketest.yml
5+
# Iterates through all sample shims and applies their labels to all nodes
6+
# using the current kubernetes context.
7+
# Waits for all corresponding Shim resources to be ready, else fails.
8+
9+
for shim_file in $(ls config/samples/sample_shim*); do
10+
label="$(cat $shim_file | yq '.spec.nodeSelector' | tr -d '"' | tr -d '[:space:]' | sed s/:/=/g)"
11+
kubectl label node --all $label
12+
13+
shim_name="$(cat $shim_file | yq '.metadata.name')"
14+
timeout=300
15+
SECONDS=0 # Reset the internal bash timer to 0
16+
success=false
17+
18+
echo "Waiting for the $shim_name shim to be ready/installed..."
19+
20+
while [[ $SECONDS -lt $timeout ]]; do
21+
# Fetch both nodes and nodesReady
22+
read -r nodes nodesReady <<< $(kubectl get shim "$shim_name" \
23+
-o jsonpath='{.status.nodes} {.status.nodesReady}' 2>/dev/null)
24+
25+
# Check to see if all nodes are ready
26+
if [[ -n "$nodes" ]] && [[ -n "$nodesReady" ]] && [[ "$nodes" -eq "$nodesReady" ]]; then
27+
echo "Success: all nodes have the $shim_name shim installed."
28+
success=true
29+
break
30+
fi
31+
32+
sleep 2
33+
done
34+
35+
if [[ "${success}" != "true" ]]; then
36+
echo "Error: Timed out after ${timeout}s waiting for the $shim_name shim to be ready."
37+
exit 1
38+
fi
39+
done

0 commit comments

Comments
 (0)