diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 899ab6346dc..5412cbfd77c 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -84,8 +84,9 @@ const ( // ReasonInvalidWorkspaceBinding indicates that a Pipeline expects a workspace but a // PipelineRun has provided an invalid binding. ReasonInvalidWorkspaceBinding = "InvalidWorkspaceBindings" - // ReasonInvalidServiceAccountMapping indicates that PipelineRun.Spec.TaskRunSpecs[].TaskServiceAccountName is defined with a wrong taskName - ReasonInvalidServiceAccountMapping = "InvalidServiceAccountMappings" + // ReasonInvalidTaskRunSpec indicates that PipelineRun.Spec.TaskRunSpecs[].PipelineTaskName is defined with + // a not exist taskName in pipelineSpec. + ReasonInvalidTaskRunSpec = "InvalidTaskRunSpecs" // ReasonParameterTypeMismatch indicates that the reason for the failure status is that // parameter(s) declared in the PipelineRun do not have the some declared type as the // parameters(s) declared in the Pipeline that they are supposed to override. @@ -512,7 +513,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1.PipelineRun, getPipel // Ensure that the TaskRunSpecs defined are correct. if err := resources.ValidateTaskRunSpecs(pipelineSpec, pr); err != nil { - pr.Status.MarkFailed(ReasonInvalidServiceAccountMapping, + pr.Status.MarkFailed(ReasonInvalidTaskRunSpec, "PipelineRun %s/%s doesn't define taskRunSpecs correctly: %s", pr.Namespace, pr.Name, err) return controller.NewPermanentError(err) diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 512ac93d33f..d02bb8264d3 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -7049,6 +7049,24 @@ spec: params: - name: platform value: linux +`), + parse.MustParseV1PipelineRun(t, ` +metadata: + name: pipelinerun-with-invalid-taskrunspecs + namespace: foo +spec: + taskRunSpecs: + - metadata: + annotations: + env: test + pipelineTaskName: invalid-task-name + pipelineSpec: + tasks: + - name: pt0 + taskSpec: + steps: + - image: foo:latest + serviceAccountName: test-sa `), } @@ -7080,6 +7098,9 @@ spec: }, { name: "pipelinerun-matrix-param-invalid-type", reason: ReasonInvalidMatrixParameterTypes, + }, { + name: "pipelinerun-with-invalid-taskrunspecs", + reason: ReasonInvalidTaskRunSpec, }, } for _, tc := range testCases {