diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 451766624d3..418ed3cc2c9 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -1290,7 +1290,7 @@ status: image: busybox script: 'exit 0' conditions: - - message: "Tasks Completed: 2 (Failed: 1, Cancelled 0), Skipped: 0" + - message: "Tasks Completed: 1 (Failed: 1, Cancelled 0), Skipped: 0" reason: Failed status: "False" type: Succeeded diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go index 8ca10e4903e..b14f00fae2e 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go @@ -105,6 +105,8 @@ type pipelineRunStatusCount struct { Incomplete int // count of tasks skipped due to the relevant timeout having elapsed before the task is launched SkippedDueToTimeout int + // count of validation failed task and taskrun not created + ValidationFailed int } // ResetSkippedCache resets the skipped cache in the facts map @@ -500,7 +502,7 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, p s := facts.getPipelineTasksCount() // completed task is a collection of successful, failed, cancelled tasks (skipped tasks are reported separately) cmTasks := s.Succeeded + s.Failed + s.Cancelled + s.IgnoredFailed - totalFailedTasks := s.Failed + s.IgnoredFailed + totalFailedTasks := s.Failed + s.IgnoredFailed + s.ValidationFailed // The completion reason is set from the TaskRun completion reason // by default, set it to ReasonRunning @@ -524,6 +526,9 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, p } switch { + case s.ValidationFailed > 0: + reason = v1.PipelineRunReasonFailedValidation.String() + status = corev1.ConditionFalse case s.Failed > 0 || s.SkippedDueToTimeout > 0: // Set reason to ReasonFailed - At least one failed reason = v1.PipelineRunReasonFailed.String() @@ -719,6 +724,7 @@ func (facts *PipelineRunFacts) getPipelineTasksCount() pipelineRunStatusCount { Incomplete: 0, SkippedDueToTimeout: 0, IgnoredFailed: 0, + ValidationFailed: 0, } for _, t := range facts.State { switch { @@ -739,7 +745,7 @@ func (facts *PipelineRunFacts) getPipelineTasksCount() pipelineRunStatusCount { s.Failed++ } case t.isValidationFailed(facts.ValidationFailedTask): - s.Failed++ + s.ValidationFailed++ // increment skipped and skipped due to timeout counters since the task was skipped due to the pipeline, tasks, or finally timeout being reached before the task was launched case t.Skip(facts).SkippingReason == v1.PipelineTimedOutSkip || t.Skip(facts).SkippingReason == v1.TasksTimedOutSkip ||