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

Cleanup error message for Step container status #7405

Merged
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
10 changes: 2 additions & 8 deletions pkg/pod/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,11 @@ func extractContainerFailureMessage(logger *zap.SugaredLogger, status corev1.Con
r, _ := termination.ParseMessage(logger, msg)
for _, runResult := range r {
if runResult.ResultType == result.InternalTektonResultType && runResult.Key == "Reason" && runResult.Value == "TimeoutExceeded" {
// Newline required at end to prevent yaml parser from breaking the log help text at 80 chars
return fmt.Sprintf("%q exited because the step exceeded the specified timeout limit; for logs run: kubectl -n %s logs %s -c %s\n",
status.Name,
podMetaData.Namespace, podMetaData.Name, status.Name)
return fmt.Sprintf("%q exited because the step exceeded the specified timeout limit", status.Name)
}
}
if term.ExitCode != 0 {
// Newline required at end to prevent yaml parser from breaking the log help text at 80 chars
return fmt.Sprintf("%q exited with code %d (image: %q); for logs run: kubectl -n %s logs %s -c %s\n",
status.Name, term.ExitCode, status.ImageID,
podMetaData.Namespace, podMetaData.Name, status.Name)
return fmt.Sprintf("%q exited with code %d", status.Name, term.ExitCode)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/pod/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func TestMakeTaskRunStatus(t *testing.T) {
}},
},
want: v1.TaskRunStatus{
Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-failure\" exited with code 123 (image: \"image-id\"); for logs run: kubectl -n foo logs pod -c step-failure\n"),
Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-failure\" exited with code 123"),
TaskRunStatusFields: v1.TaskRunStatusFields{
Steps: []v1.StepState{{
ContainerState: corev1.ContainerState{
Expand Down Expand Up @@ -1180,7 +1180,7 @@ func TestMakeTaskRunStatus(t *testing.T) {
},
},
want: v1.TaskRunStatus{
Status: statusFailure(v1.TaskRunReasonFailed.String(), "init container failed, \"init-A\" exited with code 1 (image: \"init-image-id-A\"); for logs run: kubectl -n foo logs pod -c init-A\n"),
Status: statusFailure(v1.TaskRunReasonFailed.String(), "init container failed, \"init-A\" exited with code 1"),
TaskRunStatusFields: v1.TaskRunStatusFields{
Steps: []v1.StepState{{
ContainerState: corev1.ContainerState{
Expand Down Expand Up @@ -1621,7 +1621,7 @@ func TestMakeRunStatusJSONError(t *testing.T) {
},
}
wantTr := v1.TaskRunStatus{
Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-non-json\" exited with code 1 (image: \"image\"); for logs run: kubectl -n foo logs pod -c step-non-json\n"),
Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-non-json\" exited with code 1"),
TaskRunStatusFields: v1.TaskRunStatusFields{
PodName: "pod",
Steps: []v1.StepState{{
Expand Down
Loading