@@ -80,112 +80,21 @@ jobs:
8080 - name : K8s Apply
8181 run : |
8282 make kustomize-local-apply
83- echo "=== Verifying job creation ==="
84- kubectl get jobs -n pokeapi
8583 kubectl proxy &
8684 sleep 1
8785 bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/
8886 - name : Set default namespace and print info
8987 run : |
9088 kubectl config set-context --current --namespace pokeapi
9189 kubectl describe deployment
92- echo "=== All resources in namespace ==="
93- kubectl get all -n pokeapi
94- echo "=== Checking for job creation errors ==="
95- kubectl get events -n pokeapi --sort-by='.lastTimestamp' | tail -20
9690 - name : Migrate and build data
9791 run : |
98- echo "=== Starting database migration at $(date) ==="
9992 make k8s-migrate
100- echo "=== Starting database build at $(date) ==="
10193 make k8s-build-db
102- echo "=== Database build completed at $(date) ==="
103- echo "=== Testing endpoint availability ==="
104- echo "Testing basic PokeAPI endpoint:"
105- curl -f -s --max-time 10 -o /dev/null -w "HTTP Status: %{http_code}\n" http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/pokemon/1/ || echo "Basic endpoint failed"
106- echo "Testing pal-park-area endpoint:"
107- curl -f -s --max-time 10 -o /dev/null -w "HTTP Status: %{http_code}\n" http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/pal-park-area/5/ || echo "Pal-park-area endpoint failed"
108- echo "=== Waiting for pal-park-area endpoint ==="
10994 bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/pal-park-area/5/
110- - name : Debug pod status before GraphQL load
111- run : |
112- echo "=== Pod Status ==="
113- kubectl get pods -n pokeapi
114- echo "=== Service Status ==="
115- kubectl get svc -n pokeapi
116- echo "=== Job Status ==="
117- kubectl get jobs -n pokeapi
118- echo "=== PokeAPI Logs (last 10 lines) ==="
119- kubectl logs -l component=pokeapi -n pokeapi --tail=10 || echo "No PokeAPI logs yet"
120- echo "=== Checking if pal-park-area data exists ==="
121- kubectl exec -n pokeapi deployment/pokeapi -- python manage.py shell -c "from pokemon_v2.models import PalParkArea; print(f'PalParkArea count: {PalParkArea.objects.count()}')" || echo "Failed to check PalParkArea data"
122- echo "=== Checking for failed/error pods ==="
123- error_pods=$(kubectl get pods -n pokeapi -o jsonpath='{.items[?(@.status.phase=="Failed" || @.status.phase=="Error")].metadata.name}')
124- if [ -n "$error_pods" ]; then
125- echo "Found error/failed pods, showing logs:"
126- for pod in $error_pods; do
127- echo "=== Logs for $pod ==="
128- kubectl logs $pod -n pokeapi --tail=50 || echo "No logs available for $pod"
129- done
130- else
131- echo "No error/failed pods found"
132- fi
133-
134- - name : Debug network connectivity
135- run : |
136- echo "=== Testing PokeAPI connectivity ==="
137- kubectl run debug-pod --image=curlimages/curl --rm -i --restart=Never -- curl -f -s --max-time 10 http://pokeapi:80/api/v2/pokemon/1/ || echo "PokeAPI not reachable"
138-
139- - name : Create job manually if missing
140- run : |
141- echo "=== Checking if job exists before manual creation ==="
142- if ! kubectl get job load-graphql -n pokeapi >/dev/null 2>&1; then
143- echo "Job missing - attempting manual creation"
144- kubectl apply -f Resources/k8s/kustomize/base/jobs/load-graphql.yaml
145- echo "=== Job created, checking status ==="
146- kubectl get job load-graphql -n pokeapi
147- else
148- echo "Job already exists"
149- fi
150- echo "=== Testing endpoint from within cluster ==="
151- kubectl run test-endpoint --image=curlimages/curl --rm -i --restart=Never -- curl -f -s --max-time 10 -o /dev/null -w "HTTP Status: %{http_code}\n" http://pokeapi:80/api/v2/pal-park-area/5/ || echo "Endpoint not accessible from within cluster"
152-
15395 - name : K8s wait for job
15496 run : |
155- echo "=== Starting job wait at $(date) ==="
156- echo "=== Job status before wait ==="
157- kubectl get job load-graphql -n pokeapi -o wide
158- echo "=== Pod status before wait ==="
159- kubectl get pods -n pokeapi -o wide
160-
161- # Check if job is already failed
162- job_status=$(kubectl get job load-graphql -n pokeapi -o jsonpath='{.status.conditions[?(@.type=="Failed")].status}' 2>/dev/null || echo "")
163- if [ "$job_status" = "True" ]; then
164- echo "=== Job already failed, getting debug info ==="
165- echo "Job status:"
166- kubectl get job load-graphql -n pokeapi -o yaml
167- echo "Pod status:"
168- kubectl get pods -n pokeapi
169- echo "Init container logs:"
170- kubectl logs job/load-graphql -n pokeapi -c pokeapi-last-built-resource-connection-checker --tail=20
171- echo "Main container logs:"
172- kubectl logs job/load-graphql -n pokeapi -c load-graphql --tail=20 || echo "Main container not started"
173- exit 1
174- fi
175-
176- kubectl wait --timeout=600s --for=condition=complete job/load-graphql || {
177- echo "=== JOB TIMEOUT DEBUG INFO at $(date) ==="
178- echo "Job status:"
179- kubectl get job load-graphql -n pokeapi -o yaml
180- echo "Pod status:"
181- kubectl get pods -n pokeapi
182- echo "Init container logs:"
183- kubectl logs job/load-graphql -n pokeapi -c pokeapi-last-built-resource-connection-checker --tail=20
184- echo "Main container logs:"
185- kubectl logs job/load-graphql -n pokeapi -c load-graphql --tail=20 || echo "Main container not started"
186- exit 1
187- }
188- echo "=== Job completed successfully at $(date) ==="
97+ kubectl wait --timeout=600s --for=condition=complete job/load-graphql
18998 last_command=$(kubectl get job -o jsonpath='{.status.succeeded}' load-graphql)
19099 test "$last_command" -eq 1
191100 - name : Get GQL output
@@ -202,4 +111,4 @@ jobs:
202111 - name : Assert containers running
203112 run : |
204113 last_command=$(docker ps | grep 'pokeapi-' | wc -l)
205- test "$last_command" -eq 5
114+ test "$last_command" -eq 5
0 commit comments