Skip to content

Commit

Permalink
Error sweep: correct InvalidPipelineResultReference failure reason
Browse files Browse the repository at this point in the history
This commit corrects the PipelineRunReason which previously indicates
the invalid TaskResultReference to be its actual meaning which should be
InvalidPipelineResultReference.

/kind cleanup
  • Loading branch information
JeromeJu committed Dec 7, 2023
1 parent b6d27a8 commit 676e4a6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,10 @@ associated Pipeline is an invalid graph (a.k.a wrong order, cycle, …)</p>
</tr><tr><td><p>&#34;InvalidParamValue&#34;</p></td>
<td><p>PipelineRunReasonInvalidParamValue indicates that the PipelineRun Param input value is not allowed.</p>
</td>
</tr><tr><td><p>&#34;InvalidPipelineResultReference&#34;</p></td>
<td><p>PipelineRunReasonInvalidPipelineResultReference indicates a pipeline result was declared
by the pipeline but not initialized in the pipelineTask</p>
</td>
</tr><tr><td><p>&#34;InvalidTaskResultReference&#34;</p></td>
<td><p>ReasonInvalidTaskResultReference indicates a task result was declared
but was not initialized by that task</p>
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/v1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7854,7 +7854,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(),
Expand Down

0 comments on commit 676e4a6

Please sign in to comment.