Skip to content

Commit 9d377d6

Browse files
authored
Merge pull request #58 from rajatjindal/collect-logs-from-ci
allow ci to collect logs on failure
2 parents a697b1a + 93f2afe commit 9d377d6

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ jobs:
5858
working-directory: ./deployments/k3d
5959
- name: run integration tests
6060
run: BIN_DIR="./bin" make integration-tests
61+
62+
- name: run collect debug logs
63+
if: failure()
64+
run: make tests/collect-debug-logs
65+
66+
- name: upload debug logs
67+
if: failure()
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: debug-logs
71+
path: debug-logs/
72+
retention-days: 5
73+
6174
- name: clean up k3d
6275
if: always()
6376
run: make tests/clean

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ test-workloads-delete:
5151
integration-tests: check-bins move-bins up pod-status-check workloads test-workloads-delete
5252
cargo test -p containerd-shim-spin-tests -- --nocapture
5353

54+
.PHONY: tests/collect-debug-logs
55+
tests/collect-debug-logs:
56+
./scripts/collect-debug-logs.sh 2>&1
57+
5458
.PHONY: tests/clean
5559
tests/clean:
5660
./scripts/down.sh

scripts/collect-debug-logs.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
6+
echo "collecting debug info from CI run in 'debug-logs' dir"
7+
8+
mkdir -p debug-logs
9+
10+
echo "-> k3d cluster list" > debug-logs/kubernetes.log
11+
k3d cluster list >> debug-logs/kubernetes.log
12+
echo "" >> debug-logs/kubernetes.log
13+
14+
echo "-> kubectl get pods -n default -o wide" >> debug-logs/kubernetes.log
15+
kubectl get pods -n default -o wide >> debug-logs/kubernetes.log
16+
echo "" >> debug-logs/kubernetes.log
17+
18+
echo "-> kubectl describe pods -n default" >> debug-logs/kubernetes.log
19+
kubectl describe pods -n default >> debug-logs/kubernetes.log
20+
echo "" >> debug-logs/kubernetes.log
21+
22+
for node in `k3d node list --no-headers | awk '{print $1}'`; do
23+
echo "collecting containerd logs from $node"
24+
docker cp $node:/var/lib/rancher/k3s/agent/containerd/containerd.log debug-logs/$node.containerd.log || echo "containerd.log file not found in $node"
25+
done

0 commit comments

Comments
 (0)