diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_types.go b/pkg/apis/pipeline/v1alpha1/taskrun_types.go index b0a4543fa64..d4b537aed56 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_types.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_types.go @@ -194,7 +194,8 @@ func (tr *TaskRunStatus) InitializeCloudEvents(targets []string) { // StepState reports the results of running a step in the Task. type StepState struct { corev1.ContainerState - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` + ContainerName string `json:"container,omitempty"` } // CloudEventDelivery is the target of a cloud event along with the state of diff --git a/pkg/status/taskrunpod.go b/pkg/status/taskrunpod.go index 4a956294e67..4b63f938c4d 100644 --- a/pkg/status/taskrunpod.go +++ b/pkg/status/taskrunpod.go @@ -36,6 +36,7 @@ func UpdateStatusFromPod(taskRun *v1alpha1.TaskRun, pod *corev1.Pod, resourceLis taskRun.Status.Steps = append(taskRun.Status.Steps, v1alpha1.StepState{ ContainerState: *s.State.DeepCopy(), Name: resources.TrimContainerNamePrefix(s.Name), + ContainerName: s.Name, }) } } diff --git a/pkg/status/taskrunpod_test.go b/pkg/status/taskrunpod_test.go index 2d5518a839b..c1374ac588e 100644 --- a/pkg/status/taskrunpod_test.go +++ b/pkg/status/taskrunpod_test.go @@ -77,7 +77,8 @@ func TestUpdateStatusFromPod(t *testing.T) { Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, }}, - Name: "state-name", + Name: "state-name", + ContainerName: "step-state-name", }}, }, }, { @@ -106,7 +107,8 @@ func TestUpdateStatusFromPod(t *testing.T) { Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, }}, - Name: "state-name", + Name: "state-name", + ContainerName: "step-state-name", }}, }, }, { @@ -131,7 +133,8 @@ func TestUpdateStatusFromPod(t *testing.T) { Terminated: &corev1.ContainerStateTerminated{ ExitCode: 0, }}, - Name: "step-push", + Name: "step-push", + ContainerName: "step-step-push", }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -155,7 +158,8 @@ func TestUpdateStatusFromPod(t *testing.T) { ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, - Name: "running-step", + Name: "running-step", + ContainerName: "step-running-step", }}, }, }, { @@ -189,7 +193,8 @@ func TestUpdateStatusFromPod(t *testing.T) { Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, }}, - Name: "failure", + Name: "failure", + ContainerName: "step-failure", }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -260,7 +265,8 @@ func TestUpdateStatusFromPod(t *testing.T) { Message: "i'm pending", }, }, - Name: "status-name", + Name: "status-name", + ContainerName: "step-status-name", }}, }, }, { @@ -363,7 +369,8 @@ func TestUpdateStatusFromPod(t *testing.T) { ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, - Name: "running-step", + Name: "running-step", + ContainerName: "step-running-step", }}, }, }} { diff --git a/test/taskrun_test.go b/test/taskrun_test.go index 89fdcaaf524..1bb9fd51c5a 100644 --- a/test/taskrun_test.go +++ b/test/taskrun_test.go @@ -78,7 +78,8 @@ func TestTaskRunFailure(t *testing.T) { Reason: "Completed", }, }, - Name: "hello", + Name: "hello", + ContainerName: "step-hello", }, { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ @@ -86,7 +87,8 @@ func TestTaskRunFailure(t *testing.T) { Reason: "Error", }, }, - Name: "exit", + Name: "exit", + ContainerName: "step-exit", }, { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ @@ -94,7 +96,8 @@ func TestTaskRunFailure(t *testing.T) { Reason: "Completed", }, }, - Name: "world", + Name: "world", + ContainerName: "step-world", }} ignoreFields := cmpopts.IgnoreFields(corev1.ContainerStateTerminated{}, "StartedAt", "FinishedAt", "ContainerID") if d := cmp.Diff(taskrun.Status.Steps, expectedStepState, ignoreFields); d != "" {