Skip to content

Commit

Permalink
allow ci to collect logs on failure
Browse files Browse the repository at this point in the history
Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
  • Loading branch information
rajatjindal committed Apr 2, 2024
1 parent a697b1a commit 93f2afe
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ jobs:
working-directory: ./deployments/k3d
- name: run integration tests
run: BIN_DIR="./bin" make integration-tests

- name: run collect debug logs
if: failure()
run: make tests/collect-debug-logs

- name: upload debug logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: debug-logs
path: debug-logs/
retention-days: 5

- name: clean up k3d
if: always()
run: make tests/clean
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ test-workloads-delete:
integration-tests: check-bins move-bins up pod-status-check workloads test-workloads-delete
cargo test -p containerd-shim-spin-tests -- --nocapture

.PHONY: tests/collect-debug-logs
tests/collect-debug-logs:
./scripts/collect-debug-logs.sh 2>&1

.PHONY: tests/clean
tests/clean:
./scripts/down.sh
Expand Down
25 changes: 25 additions & 0 deletions scripts/collect-debug-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -euo pipefail


echo "collecting debug info from CI run in 'debug-logs' dir"

mkdir -p debug-logs

echo "-> k3d cluster list" > debug-logs/kubernetes.log
k3d cluster list >> debug-logs/kubernetes.log
echo "" >> debug-logs/kubernetes.log

echo "-> kubectl get pods -n default -o wide" >> debug-logs/kubernetes.log
kubectl get pods -n default -o wide >> debug-logs/kubernetes.log
echo "" >> debug-logs/kubernetes.log

echo "-> kubectl describe pods -n default" >> debug-logs/kubernetes.log
kubectl describe pods -n default >> debug-logs/kubernetes.log
echo "" >> debug-logs/kubernetes.log

for node in `k3d node list --no-headers | awk '{print $1}'`; do
echo "collecting containerd logs from $node"
docker cp $node:/var/lib/rancher/k3s/agent/containerd/containerd.log debug-logs/$node.containerd.log || echo "containerd.log file not found in $node"
done

0 comments on commit 93f2afe

Please sign in to comment.