From 0db72d2a007dc2057f6007be6121056a43d2db43 Mon Sep 17 00:00:00 2001 From: JeromeJu Date: Wed, 22 Nov 2023 21:06:18 +0000 Subject: [PATCH] Cleanup error message for Step container status This commit cleans up the error message for the step container status. fixes: #7013 --- pkg/pod/status.go | 10 ++-------- pkg/pod/status_test.go | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pkg/pod/status.go b/pkg/pod/status.go index 7c52ca4ce32..a8a6d5ae57d 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -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) } } diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index 77c0176399a..417bdc6404c 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -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{ @@ -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{ @@ -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{{