Skip to content

Commit 46e2405

Browse files
committed
Add job failure checks and enhanced debugging in Kubernetes workflow
- Implemented checks to determine if the load-graphql job has already failed, providing detailed debug information if so. - Added commands to retrieve job and pod statuses, along with logs from both init and main containers for better troubleshooting.
1 parent 93f667b commit 46e2405

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/docker-k8s.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ jobs:
148148
kubectl get job load-graphql -n pokeapi -o wide
149149
echo "=== Pod status before wait ==="
150150
kubectl get pods -n pokeapi -o wide
151+
152+
# Check if job is already failed
153+
job_status=$(kubectl get job load-graphql -n pokeapi -o jsonpath='{.status.conditions[?(@.type=="Failed")].status}' 2>/dev/null || echo "")
154+
if [ "$job_status" = "True" ]; then
155+
echo "=== Job already failed, getting debug info ==="
156+
echo "Job status:"
157+
kubectl get job load-graphql -n pokeapi -o yaml
158+
echo "Pod status:"
159+
kubectl get pods -n pokeapi
160+
echo "Init container logs:"
161+
kubectl logs job/load-graphql -n pokeapi -c pokeapi-last-built-resource-connection-checker --tail=20
162+
echo "Main container logs:"
163+
kubectl logs job/load-graphql -n pokeapi -c load-graphql --tail=20 || echo "Main container not started"
164+
exit 1
165+
fi
166+
151167
kubectl wait --timeout=600s --for=condition=complete job/load-graphql || {
152168
echo "=== JOB TIMEOUT DEBUG INFO at $(date) ==="
153169
echo "Job status:"

0 commit comments

Comments
 (0)