Skip to content

Commit 548d1d9

Browse files
prontclaude
andcommitted
chore(ci): collect K8s diagnostics on E2E test failure
Add a diagnostic step to the K8s E2E workflow that runs on failure. Captures pod logs, events, configs, and node resource usage to avoid deep manual investigation when tests fail. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b59c9a2 commit 548d1d9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/k8s_e2e.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,37 @@ jobs:
209209
max_attempts: 3
210210
command: make test-e2e-kubernetes
211211

212+
- name: Collect K8s diagnostics on failure
213+
if: failure()
214+
run: |
215+
set +e +o pipefail
216+
# Best-effort diagnostics -- never fail the job
217+
run_diag() { local label="$1"; shift; echo "--- $label ---"; "$@" 2>&1 || true; echo; }
218+
# For commands with pipes that can't be passed as args
219+
run_diag_sh() { echo "--- $1 ---"; bash -c "$2" 2>&1 || true; echo; }
220+
221+
run_diag "Cluster-wide pods" kubectl get pods -A -o wide
222+
run_diag "Cluster-wide events" kubectl get events -A --sort-by=.metadata.creationTimestamp
223+
run_diag "Nodes" kubectl get nodes -o wide
224+
225+
for ns in $(kubectl get namespaces -o jsonpath='{.items[*].metadata.name}' 2>/dev/null | tr ' ' '\n' | grep -E '^vector-' || true); do
226+
echo "=========================================="
227+
echo "=== Namespace: $ns ==="
228+
echo "=========================================="
229+
run_diag "Pods" kubectl get pods -n "$ns" -o wide
230+
run_diag "Pod descriptions" kubectl describe pods -n "$ns"
231+
run_diag "Events" kubectl get events -n "$ns" --sort-by=.metadata.creationTimestamp
232+
run_diag "ConfigMaps" kubectl get configmaps -n "$ns" -o yaml
233+
234+
for pod in $(kubectl get pods -n "$ns" -o jsonpath='{.items[*].metadata.name}' 2>/dev/null || true); do
235+
run_diag "Logs: $pod" kubectl logs -n "$ns" "$pod" --all-containers=true --tail=100
236+
run_diag "Previous logs: $pod" kubectl logs -n "$ns" "$pod" --all-containers=true --previous --tail=50
237+
done
238+
done
239+
240+
run_diag_sh "Node resources" "kubectl describe nodes | grep -A20 'Allocated resources'"
241+
run_diag "Minikube logs" minikube logs --length=100
242+
212243
final-result:
213244
name: K8s E2E Suite
214245
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)