From 37809f9f44d6e224cb4187de14297d1fc6d213d6 Mon Sep 17 00:00:00 2001 From: divyansh42 Date: Wed, 16 Oct 2024 20:12:40 +0530 Subject: [PATCH] Exit reconcilation and markfailed if finally is not present Signed-off-by divyansh42 --- pkg/reconciler/pipelinerun/pipelinerun.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 9069e6cbcf2..c440d85da6e 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -853,6 +853,16 @@ func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1.Pipeline // be added to the nextRpts nextRpts = nil pipelineRunFacts.ValidationFailedTask = append(pipelineRunFacts.ValidationFailedTask, rpt) + fTaskNames := pipelineRunFacts.GetFinalTaskNames() + if len(fTaskNames) == 0 { + // If finally is not present, we should mark pipelinerun as + // failed so that no further execution happens. Also, + // this will set the completion time of the pipelineRun. + // NewPermanentError should also be returned so that + // reconcilation stops here + pr.Status.MarkFailed(v1.PipelineRunReasonInvalidTaskResultReference.String(), err.Error()) + return controller.NewPermanentError(err) + } } } // GetFinalTasks only returns final tasks when a DAG is complete