diff --git a/pkg/pod/status.go b/pkg/pod/status.go index 21988e5f51b..2716cb0fff3 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -784,6 +784,10 @@ func extractContainerFailureMessage(logger *zap.SugaredLogger, status corev1.Con } } if term.ExitCode != 0 { + // Include the termination reason, if available to add clarity for causes such as external signals, e.g. OOM + if term.Reason != "" { + return fmt.Sprintf("%q exited with code %d: %s", status.Name, term.ExitCode, term.Reason) + } return fmt.Sprintf("%q exited with code %d", status.Name, term.ExitCode) } } diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index 34a521a9eb9..08f89c7f319 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -1468,7 +1468,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, want: v1.TaskRunStatus{ - Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-one\" exited with code 137"), + Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-one\" exited with code 137: OOMKilled"), TaskRunStatusFields: v1.TaskRunStatusFields{ Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{