File tree Expand file tree Collapse file tree 2 files changed +60
-34
lines changed Expand file tree Collapse file tree 2 files changed +60
-34
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ DSPA_NS=" "
6
+ DSPO_NS=" "
7
+
8
+ while [[ " $# " -gt 0 ]]; do
9
+ case $1 in
10
+ --dspa-ns) DSPA_NS=" $2 " ; shift ;;
11
+ --dspo-ns) DSPO_NS=" $2 " ; shift ;;
12
+ * ) echo " Unknown parameter passed: $1 " ; exit 1 ;;
13
+ esac
14
+ shift
15
+ done
16
+
17
+ if [[ -z " $DSPA_NS " || -z " $DSPO_NS " ]]; then
18
+ echo " Both --dspa-ns and --dspo-ns parameters are required."
19
+ exit 1
20
+ fi
21
+
22
+ function check_namespace {
23
+ if ! kubectl get namespace " $1 " & > /dev/null; then
24
+ echo " Namespace '$1 ' does not exist."
25
+ exit 1
26
+ fi
27
+ }
28
+
29
+ function display_pod_info {
30
+ local NAMESPACE=$1
31
+ local POD_NAMES
32
+
33
+ POD_NAMES=$( kubectl -n " ${DSPA_NS} " get pods -o custom-columns=" :metadata.name" )
34
+
35
+ if [[ -z " ${POD_NAMES} " ]]; then
36
+ echo " No pods found in namespace '${NAMESPACE} '."
37
+ return
38
+ fi
39
+
40
+ for POD_NAME in ${POD_NAMES} ; do
41
+ echo " ===== Pod: ${POD_NAME} in ${NAMESPACE} ====="
42
+
43
+ echo " ----- EVENTS -----"
44
+ kubectl describe pod " ${POD_NAME} " -n " ${NAMESPACE} " | grep -A 100 Events || echo " No events found for pod ${POD_NAME} ."
45
+
46
+ echo " ----- LOGS -----"
47
+ kubectl logs " ${POD_NAME} " -n " ${NAMESPACE} " || echo " No logs found for pod ${POD_NAME} ."
48
+
49
+ echo " ==========================="
50
+ echo " "
51
+ done
52
+ }
53
+
54
+ check_namespace " $DSPA_NS "
55
+ check_namespace " $DSPO_NS "
56
+
57
+ display_pod_info " $DSPA_NS "
58
+ display_pod_info " $DSPO_NS "
Original file line number Diff line number Diff line change 55
55
56
56
- name : Collect events and logs
57
57
if : steps.test.outcome != 'success'
58
+ working-directory : ${{ github.workspace }}/.github/scripts/tests
58
59
run : |
59
- kubectl -n test-dspa get pods
60
- kubectl -n opendatahub get pods
61
-
62
- POD_NAMES=$(kubectl -n test-dspa get pods -o custom-columns=":metadata.name")
63
-
64
- for POD_NAME in ${POD_NAMES}; do
65
- echo "===== Pod: ${POD_NAME} ====="
66
-
67
- echo "----- EVENTS -----"
68
- kubectl describe pod ${POD_NAME} -n test-dspa | grep -A 100 Events
69
-
70
- echo "----- LOGS -----"
71
- kubectl logs ${POD_NAME} -n test-dspa
72
-
73
- echo "==========================="
74
- echo ""
75
- done
76
-
77
- POD_NAMES=$(kubectl -n opendatahub get pods -o custom-columns=":metadata.name")
78
-
79
- for POD_NAME in ${POD_NAMES}; do
80
- echo "===== Pod: ${POD_NAME} ====="
81
-
82
- echo "----- EVENTS -----"
83
- kubectl describe pod ${POD_NAME} -n opendatahub | grep -A 100 Events
84
-
85
- echo "----- LOGS -----"
86
- kubectl logs ${POD_NAME} -n opendatahub
87
-
88
- echo "==========================="
89
- echo ""
90
- done
91
-
60
+ ./collect_logs.sh --dspa-ns test-dspa --dspo-ns opendatahub
92
61
exit 1
93
-
You can’t perform that action at this time.
0 commit comments