Skip to content

Commit 008e314

Browse files
committed
Add oomkilled reason
1 parent e91bbdf commit 008e314

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/pod/status.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,15 @@ 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
}
790794

791-
return ""
795+
return ""
792796
}
793797

794798
// IsPodExceedingNodeResources returns true if the Pod's status indicates there

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)