Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow ci to collect logs on failure #58

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading