Skip to content

Commit 69b25f8

Browse files
committed
Report pod.status.message when pod fails
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
1 parent e446ce5 commit 69b25f8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/util/kube/pod.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ func GetPodTerminateMessage(pod *corev1api.Pod) string {
184184
}
185185
}
186186

187+
if pod.Status.Message != "" {
188+
message += pod.Status.Message + "/"
189+
}
190+
187191
return message
188192
}
189193

pkg/util/kube/pod_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,27 @@ func TestGetPodTerminateMessage(t *testing.T) {
520520
},
521521
message: "message-1/message-2/message-3/",
522522
},
523+
{
524+
name: "with pod status message",
525+
pod: &corev1api.Pod{
526+
Status: corev1api.PodStatus{
527+
Message: "pod-message",
528+
},
529+
},
530+
message: "pod-message/",
531+
},
532+
{
533+
name: "with termination and pod status message",
534+
pod: &corev1api.Pod{
535+
Status: corev1api.PodStatus{
536+
ContainerStatuses: []corev1api.ContainerStatus{
537+
{Name: "container-1", State: corev1api.ContainerState{Terminated: &corev1api.ContainerStateTerminated{Message: "message-1"}}},
538+
},
539+
Message: "pod-message",
540+
},
541+
},
542+
message: "message-1/pod-message/",
543+
},
523544
}
524545

525546
for _, test := range tests {

0 commit comments

Comments
 (0)