From b69347d97e99dc2ca60892925e32d4a0a3e24d3a Mon Sep 17 00:00:00 2001 From: JeromeJu Date: Thu, 7 Dec 2023 00:18:42 +0000 Subject: [PATCH] Error sweep: correct InvalidPipelineResultReference failure reason This commit corrects the PipelineRunReason which previously indicates the invalid TaskResultReference to be its actual meaning which should be InvalidPipelineResultReference. /kind cleanup --- docs/pipeline-api.md | 4 ++++ pkg/apis/pipeline/v1/pipelinerun_types.go | 3 +++ pkg/reconciler/pipelinerun/pipelinerun.go | 6 ++++-- pkg/reconciler/pipelinerun/pipelinerun_test.go | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/pipeline-api.md b/docs/pipeline-api.md index 99c4b7f8483..4d09b848f60 100644 --- a/docs/pipeline-api.md +++ b/docs/pipeline-api.md @@ -2005,6 +2005,10 @@ associated Pipeline is an invalid graph (a.k.a wrong order, cycle, …)

"InvalidParamValue"

PipelineRunReasonInvalidParamValue indicates that the PipelineRun Param input value is not allowed.

+

"InvalidPipelineResultReference"

+

PipelineRunReasonInvalidPipelineResultReference indicates a pipeline result was declared +by the pipeline but not initialized in the pipelineTask

+

"InvalidTaskResultReference"

ReasonInvalidTaskResultReference indicates a task result was declared but was not initialized by that task

diff --git a/pkg/apis/pipeline/v1/pipelinerun_types.go b/pkg/apis/pipeline/v1/pipelinerun_types.go index 34be57243ae..1cc3b2e6dbc 100644 --- a/pkg/apis/pipeline/v1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1/pipelinerun_types.go @@ -399,6 +399,9 @@ const ( // ReasonInvalidTaskResultReference indicates a task result was declared // but was not initialized by that task PipelineRunReasonInvalidTaskResultReference PipelineRunReason = "InvalidTaskResultReference" + // PipelineRunReasonInvalidPipelineResultReference indicates a pipeline result was declared + // by the pipeline but not initialized in the pipelineTask + PipelineRunReasonInvalidPipelineResultReference PipelineRunReason = "InvalidPipelineResultReference" // ReasonRequiredWorkspaceMarkedOptional indicates an optional workspace // has been passed to a Task that is expecting a non-optional workspace PipelineRunReasonRequiredWorkspaceMarkedOptional PipelineRunReason = "RequiredWorkspaceMarkedOptional" diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 32c3254e54c..ae28207ffaa 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -686,8 +686,10 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1.PipelineRun, getPipel } if err := resources.ValidatePipelineResults(pipelineSpec, pipelineRunFacts.State); err != nil { - logger.Errorf("Failed to resolve task result reference for %q with error %v", pr.Name, err) - pr.Status.MarkFailed(v1.PipelineRunReasonInvalidTaskResultReference.String(), err.Error()) + logger.Errorf("Failed to resolve pipeline result reference for %q with error %w", pr.Name, err) + pr.Status.MarkFailed(v1.PipelineRunReasonInvalidPipelineResultReference.String(), + "Failed to resolve pipeline result reference for %q with error %w", + pr.Name, err) return controller.NewPermanentError(err) } diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index a9c2b462d30..6a1dd43cca2 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -7858,7 +7858,7 @@ spec: reason: v1.PipelineRunReasonInvalidTaskResultReference.String(), }, { name: "pipelinerun-pipeline-result-invalid-result-variable", - reason: v1.PipelineRunReasonInvalidTaskResultReference.String(), + reason: v1.PipelineRunReasonInvalidPipelineResultReference.String(), }, { name: "pipelinerun-with-optional-workspace-validation", reason: v1.PipelineRunReasonRequiredWorkspaceMarkedOptional.String(),