Skip to content

Commit

Permalink
Add CouldntGetPipelineResult PipelineRunReason
Browse files Browse the repository at this point in the history
This commit adds the PipelineRunReasonCouldntGetPipelineResult which was
previously conflated in PipelineRunReasonFailedValidation. It is now
separated in order to keep the PipelineRunStatus failure reason
granular.

/kind cleanup
  • Loading branch information
JeromeJu authored and tekton-robot committed Dec 6, 2023
1 parent 66eea3a commit d1b8f29
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
5 changes: 5 additions & 0 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,11 @@ all of the running TaskRuns as cancelled failed.</p>
<td><p>ReasonCouldntGetPipeline indicates that the reason for the failure status is that the
associated Pipeline couldn&rsquo;t be retrieved</p>
</td>
</tr><tr><td><p>&#34;CouldntGetPipelineResult&#34;</p></td>
<td><p>PipelineRunReasonCouldntGetPipelineResult indicates that the pipeline fails to retrieve the
referenced result. This could be due to failed TaskRuns or Runs that were supposed to produce
the results</p>
</td>
</tr><tr><td><p>&#34;CouldntGetTask&#34;</p></td>
<td><p>ReasonCouldntGetTask indicates that the reason for the failure status is that the
associated Pipeline&rsquo;s Tasks couldn&rsquo;t all be retrieved</p>
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/pipeline/v1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ const (
// ReasonFailedValidation indicates that the reason for failure status is
// that pipelinerun failed runtime validation
PipelineRunReasonFailedValidation PipelineRunReason = "PipelineValidationFailed"
// PipelineRunReasonCouldntGetPipelineResult indicates that the pipeline fails to retrieve the
// referenced result. This could be due to failed TaskRuns or Runs that were supposed to produce
// the results
PipelineRunReasonCouldntGetPipelineResult PipelineRunReason = "CouldntGetPipelineResult"
// ReasonInvalidGraph indicates that the reason for the failure status is that the
// associated Pipeline is an invalid graph (a.k.a wrong order, cycle, …)
PipelineRunReasonInvalidGraph PipelineRunReason = "PipelineInvalidGraph"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1.PipelineRun, getPipel
pr.Status.Results, err = resources.ApplyTaskResultsToPipelineResults(ctx, pipelineSpec.Results,
pipelineRunFacts.State.GetTaskRunsResults(), pipelineRunFacts.State.GetRunsResults(), pipelineRunFacts.GetPipelineTaskStatus())
if err != nil {
pr.Status.MarkFailed(v1.PipelineRunReasonFailedValidation.String(), err.Error())
pr.Status.MarkFailed(v1.PipelineRunReasonCouldntGetPipelineResult.String(), err.Error())
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func ApplyTaskResultsToPipelineResults(
}

if len(invalidPipelineResults) > 0 {
return runResults, fmt.Errorf("invalid pipelineresults %v, the referred results don't exist", invalidPipelineResults)
return runResults, fmt.Errorf("invalid pipelineresults %v, the referenced results don't exist", invalidPipelineResults)
}

return runResults, nil
Expand Down
28 changes: 14 additions & 14 deletions pkg/reconciler/pipelinerun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4083,7 +4083,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [pipeline-result-1], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [pipeline-result-1], the referenced results don't exist"),
}, {
description: "object-reference-key-not-exist",
results: []v1.PipelineResult{{
Expand All @@ -4102,7 +4102,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [pipeline-result-1], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [pipeline-result-1], the referenced results don't exist"),
}, {
description: "object-results-resultname-not-exist",
results: []v1.PipelineResult{{
Expand All @@ -4121,7 +4121,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [pipeline-result-1], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [pipeline-result-1], the referenced results don't exist"),
}, {
description: "invalid-result-variable-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4135,7 +4135,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "no-taskrun-results-no-returned-results",
results: []v1.PipelineResult{{
Expand All @@ -4146,7 +4146,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
"pt1": {},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "invalid-taskrun-name-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4160,7 +4160,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "invalid-result-name-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4174,7 +4174,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "unsuccessful-taskrun-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4183,7 +4183,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
taskResults: map[string][]v1.TaskRunResult{},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "mixed-success-tasks-some-returned-results",
results: []v1.PipelineResult{{
Expand All @@ -4203,7 +4203,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
Name: "bar",
Value: *v1.NewStructuredValues("rae"),
}},
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "no-run-results-no-returned-results",
results: []v1.PipelineResult{{
Expand All @@ -4212,7 +4212,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
runResults: map[string][]v1beta1.CustomRunResult{},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "wrong-customtask-name-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4226,7 +4226,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "right-customtask-name-wrong-result-name-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4240,7 +4240,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
}},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "unsuccessful-run-no-returned-result",
results: []v1.PipelineResult{{
Expand All @@ -4251,7 +4251,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
"customtask": {},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}, {
description: "wrong-result-reference-expression",
results: []v1.PipelineResult{{
Expand All @@ -4262,7 +4262,7 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
"customtask": {},
},
expectedResults: nil,
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"),
expectedError: fmt.Errorf("invalid pipelineresults [foo], the referenced results don't exist"),
}} {
t.Run(tc.description, func(t *testing.T) {
received, err := resources.ApplyTaskResultsToPipelineResults(context.Background(), tc.results, tc.taskResults, tc.runResults, nil /*skipped tasks*/)
Expand Down

0 comments on commit d1b8f29

Please sign in to comment.