Skip to content

Commit a40dbb1

Browse files
committed
Add oomkilled reason
1 parent e91bbdf commit a40dbb1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pkg/pod/status.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,10 @@ func extractContainerFailureMessage(logger *zap.SugaredLogger, status corev1.Con
784784
}
785785
}
786786
if term.ExitCode != 0 {
787+
// Include the termination reason, if available to add clarity for causes such as external signals, e.g. OOM
788+
if term.Reason != "" {
789+
return fmt.Sprintf("%q exited with code %d: %s", status.Name, term.ExitCode, term.Reason)
790+
}
787791
return fmt.Sprintf("%q exited with code %d", status.Name, term.ExitCode)
788792
}
789793
}

pkg/pod/status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ func TestMakeTaskRunStatus(t *testing.T) {
14681468
}},
14691469
},
14701470
want: v1.TaskRunStatus{
1471-
Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-one\" exited with code 137"),
1471+
Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-one\" exited with code 137: OOMKilled"),
14721472
TaskRunStatusFields: v1.TaskRunStatusFields{
14731473
Steps: []v1.StepState{{
14741474
ContainerState: corev1.ContainerState{

0 commit comments

Comments
 (0)