diff --git a/pkg/pod/status.go b/pkg/pod/status.go index d823f229f51..523722d32c7 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -125,7 +125,7 @@ func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1.Tas sortPodContainerStatuses(pod.Status.ContainerStatuses, pod.Spec.Containers) - complete := areContainersCompleted(ctx, pod) || pod.Status.Phase == corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed + complete := areContainersCompleted(ctx, pod) || pod.Status.Phase == corev1.PodSucceeded || DidTaskRunFail(pod) if complete { onError, ok := tr.Annotations[v1.PipelineTaskOnErrorAnnotation] diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index e11b9946208..48af5fc344d 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -832,7 +832,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, want: v1.TaskRunStatus{ - Status: statusRunning(), + Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-state-name\" exited with code 123"), TaskRunStatusFields: v1.TaskRunStatusFields{ Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ @@ -843,6 +843,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Container: "step-state-name", }}, Sidecars: []v1.SidecarState{}, + // We don't actually care about the time, just that it's not nil + CompletionTime: &metav1.Time{Time: time.Now()}, }, }, }, { @@ -866,7 +868,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, want: v1.TaskRunStatus{ - Status: statusRunning(), + Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-state-name\" exited with code 123"), TaskRunStatusFields: v1.TaskRunStatusFields{ Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ @@ -878,6 +880,8 @@ func TestMakeTaskRunStatus(t *testing.T) { ImageID: "image-id", }}, Sidecars: []v1.SidecarState{}, + // We don't actually care about the time, just that it's not nil + CompletionTime: &metav1.Time{Time: time.Now()}, }, }, }, {