Skip to content

Commit 4da07a9

Browse files
authored
Fixed copy workspace error
1 parent a8c166f commit 4da07a9

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.10']
11+
python-version: ['3.13']
1212

1313
env:
1414
REALM: test
@@ -336,22 +336,60 @@ jobs:
336336
printf "%s" "$TOKEN" > access_token.txt
337337
echo "Access token saved to access_token.txt"
338338
339-
- name: Create python test pod
339+
- name: Create and populate python test pod (robust)
340340
run: |
341+
set -euo pipefail
342+
341343
NS=my-verticadb-operator
342344
POD=py-test-runner
343345
IMAGE=python:3.11-slim
346+
WAIT_TIMEOUT=180
347+
INTERVAL=3
348+
349+
kubectl create ns ${NS} --dry-run=client -o yaml | kubectl apply -f - 2>/dev/null || true
344350
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
345351
kubectl -n ${NS} run ${POD} --image=${IMAGE} --restart=Never --command -- sleep infinity
346-
kubectl -n ${NS} wait --for=condition=Ready pod/${POD} --timeout=120s
347352
348-
- name: Copy workspace and token into python pod
349-
run: |
350-
NS=my-verticadb-operator
351-
POD=py-test-runner
353+
deadline=$((SECONDS + WAIT_TIMEOUT))
354+
while [ $SECONDS -lt $deadline ]; do
355+
pod_phase=$(kubectl -n ${NS} get pod ${POD} -o jsonpath='{.status.phase}' 2>/dev/null || echo "")
356+
if [ "$pod_phase" = "Running" ]; then
357+
echo "Pod ${POD} is Running"
358+
break
359+
fi
360+
if [ -n "$pod_phase" ] && { [ "$pod_phase" = "Failed" ] || [ "$pod_phase" = "Unknown" ]; }; then
361+
echo "Pod entered non-running phase: $pod_phase"
362+
kubectl -n ${NS} describe pod ${POD} || true
363+
kubectl -n ${NS} get events --sort-by=.metadata.creationTimestamp -n ${NS} || true
364+
kubectl -n ${NS} logs ${POD} || true
365+
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
366+
exit 1
367+
fi
368+
sleep ${INTERVAL}
369+
done
370+
371+
if [ "$(kubectl -n ${NS} get pod ${POD} -o jsonpath='{.status.phase}' 2>/dev/null || echo "")" != "Running" ]; then
372+
echo "Timed out waiting for pod ${POD} to become Running"
373+
kubectl -n ${NS} describe pod ${POD} || true
374+
kubectl -n ${NS} get events --sort-by=.metadata.creationTimestamp -n ${NS} || true
375+
kubectl -n ${NS} logs ${POD} || true
376+
kubectl -n ${NS} delete pod ${POD} --ignore-not-found || true
377+
exit 1
378+
fi
379+
352380
kubectl -n ${NS} exec -i pod/${POD} -- mkdir -p /workspace
353381
tar cf - . | kubectl -n ${NS} exec -i pod/${POD} -- tar xf - -C /workspace
354-
kubectl -n ${NS} cp access_token.txt pod/${POD}:/workspace/access_token.txt
382+
383+
if kubectl -n ${NS} cp access_token.txt pod/${POD}:/workspace/access_token.txt 2>/dev/null; then
384+
echo "Token copied into pod via kubectl cp"
385+
else
386+
echo "kubectl cp failed; falling back to cat > /workspace/access_token.txt"
387+
TOKEN_CONTENT=$(cat access_token.txt)
388+
kubectl -n ${NS} exec -i pod/${POD} -- bash -lc "cat > /workspace/access_token.txt" <<EOF
389+
$TOKEN_CONTENT
390+
EOF
391+
echo "Token written into pod via fallback"
392+
fi
355393
356394
- name: Run tests inside python pod
357395
run: |
@@ -366,6 +404,11 @@ jobs:
366404
tox -e py
367405
"
368406
407+
- name: Cleanup python test pod
408+
if: always()
409+
run: |
410+
kubectl -n my-verticadb-operator delete pod py-test-runner --ignore-not-found || true
411+
369412
- name: Uninstall MinIO
370413
if: always()
371414
run: |

0 commit comments

Comments
 (0)