...
1name: 'Collect Logs'
2description: >-
3 Store any log files as artifacts.
4inputs:
5 jobname:
6 default: ${{ github.job }}
7runs:
8 using: "composite"
9 steps:
10 - name: "Gather Logs"
11 shell: bash
12 run: |
13 mkdir -p /tmp/test-logs
14 rsync \
15 --prune-empty-dirs --archive --include='*/' \
16 --include='*.xml' \
17 --include='*.tap' \
18 --include='*.log' \
19 --exclude='*' \
20 . \
21 /tmp/test-logs/checkout
22 if test -d /tmp/cov_html; then
23 rsync \
24 --archive \
25 /tmp/cov_html \
26 /tmp/test-logs/cov_html
27 fi
28 if test -d /tmp/test-data; then
29 rsync \
30 --archive \
31 /tmp/test-data_html \
32 /tmp/test-logs/test-data
33 fi
34 if test -d ~/.cache/telepresence/logs; then
35 rsync \
36 --archive \
37 ~/.cache/telepresence/logs \
38 /tmp/test-logs/telepresence
39 fi
40 if test -f ~/.kube/config; then
41 make tools/bin/kubectl
42 mkdir /tmp/test-logs/cluster
43 tools/bin/kubectl get hosts --all-namespaces -o yaml >/tmp/test-logs/cluster/all-hosts.yaml || true
44 tools/bin/kubectl get pods --all-namespaces >/tmp/test-logs/cluster/all-pods.txt || true
45 tools/bin/kubectl describe pods --all-namespaces >/tmp/test-logs/cluster/all-pods-described.txt || true
46
47 tools/bin/kubectl get pods --all-namespaces -ocustom-columns="name:.metadata.name,namespace:.metadata.namespace" --no-headers | while read -r name namespace; do
48 echo "Pulling logs for ${name}.${namespace}"
49 tools/bin/kubectl --namespace="$namespace" logs "$name" >"/tmp/test-logs/cluster/pod.${namespace}.${name}.log" || true
50 tools/bin/kubectl exec -n $namespace $name -- tar -czf /tmp/ambassador-config-base.tgz /tmp/ambassador --exclude=secrets-decoded --exclude=webui --exclude=sidecars && kubectl cp -n "$namespace" "$name":/tmp/ambassador-config-base.tgz /tmp/test-logs/cluster/${namespace}-${name}-pod-config-base.tgz || true
51 done
52
53 tools/bin/kubectl cp xfpredirect:/tmp/ambassador/snapshots /tmp/test-logs/cluster/xfpredirect.snapshots || true
54 fi
55 cp /tmp/*.yaml /tmp/test-logs || true
56 - name: "Upload Logs"
57 uses: actions/upload-artifact@v3
58 with:
59 name: logs-${{ inputs.jobname }}
60 path: /tmp/test-logs
61 if-no-files-found: ignore
View as plain text