From 2f69f1e49b6abbecef65801728ec455af2c18df5 Mon Sep 17 00:00:00 2001 From: Xinru Zhang Date: Tue, 20 Dec 2022 14:34:01 -0500 Subject: [PATCH] Fix Wrong Condition Reason When Fails to Stop Sidecars for A Finished TaskRun Prior to this commit, if a TaskRun fails to stop sidecars, the failure reason is `TaskRunResolutionFailed` which does not make sense at all. This commit creates a new reason for StopSideCar failure, and fix the wrong condition reason. --- pkg/apis/pipeline/v1beta1/taskrun_types.go | 2 ++ pkg/reconciler/taskrun/taskrun.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/apis/pipeline/v1beta1/taskrun_types.go b/pkg/apis/pipeline/v1beta1/taskrun_types.go index 69c2b24e0c0..5253c651676 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_types.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_types.go @@ -188,6 +188,8 @@ const ( AwaitingTaskRunResults TaskRunReason = "AwaitingTaskRunResults" // TaskRunReasonResultLargerThanAllowedLimit is the reason set when one of the results exceeds its maximum allowed limit of 1 KB TaskRunReasonResultLargerThanAllowedLimit TaskRunReason = "TaskRunResultLargerThanAllowedLimit" + // TaskRunReasonStopSidecarFailed indicates that the sidecar is not properly stopped. + TaskRunReasonStopSidecarFailed = "TaskRunStopSidecarFailed" ) func (t TaskRunReason) String() string { diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index 077cdd54df8..09c7d18863f 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -285,7 +285,7 @@ func (c *Reconciler) stopSidecars(ctx context.Context, tr *v1beta1.TaskRun) erro return controller.NewPermanentError(err) } else if err != nil { logger.Errorf("Error stopping sidecars for TaskRun %q: %v", tr.Name, err) - tr.Status.MarkResourceFailed(podconvert.ReasonFailedResolution, err) + tr.Status.MarkResourceFailed(v1beta1.TaskRunReasonStopSidecarFailed, err) } return nil }