Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds container name to taskrun.status.steps #1100

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/apis/pipeline/v1alpha1/taskrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/status/taskrunpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand Down
21 changes: 14 additions & 7 deletions pkg/status/taskrunpod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func TestUpdateStatusFromPod(t *testing.T) {
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 123,
}},
Name: "state-name",
Name: "state-name",
ContainerName: "step-state-name",
}},
},
}, {
Expand Down Expand Up @@ -106,7 +107,8 @@ func TestUpdateStatusFromPod(t *testing.T) {
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 123,
}},
Name: "state-name",
Name: "state-name",
ContainerName: "step-state-name",
}},
},
}, {
Expand All @@ -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()},
Expand All @@ -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",
}},
},
}, {
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -260,7 +265,8 @@ func TestUpdateStatusFromPod(t *testing.T) {
Message: "i'm pending",
},
},
Name: "status-name",
Name: "status-name",
ContainerName: "step-status-name",
}},
},
}, {
Expand Down Expand Up @@ -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",
}},
},
}} {
Expand Down
9 changes: 6 additions & 3 deletions test/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,26 @@ func TestTaskRunFailure(t *testing.T) {
Reason: "Completed",
},
},
Name: "hello",
Name: "hello",
ContainerName: "step-hello",
}, {
ContainerState: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 1,
Reason: "Error",
},
},
Name: "exit",
Name: "exit",
ContainerName: "step-exit",
}, {
ContainerState: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 0,
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 != "" {
Expand Down