Skip to content

Commit a161298

Browse files
divyansh42tekton-robot
authored andcommitted
Remove permanent error and improve skip logic
Signed-off-by: divyansh42 <[email protected]>
1 parent 37809f9 commit a161298

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

pkg/reconciler/pipelinerun/pipelinerun.go

+2-11
Original file line numberDiff line numberDiff line change
@@ -849,20 +849,11 @@ func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1.Pipeline
849849
logger.Infof("Failed to resolve task result reference for %q with error %v", pr.Name, err)
850850
// If there is an error encountered, no new task
851851
// will be scheduled, hence nextRpts should be empty
852-
// if finally tasks are found, then those tasks will
852+
// If finally tasks are found, then those tasks will
853853
// be added to the nextRpts
854854
nextRpts = nil
855+
logger.Infof("Adding the task %q to the validation failed list", rpt.ResolvedTask)
855856
pipelineRunFacts.ValidationFailedTask = append(pipelineRunFacts.ValidationFailedTask, rpt)
856-
fTaskNames := pipelineRunFacts.GetFinalTaskNames()
857-
if len(fTaskNames) == 0 {
858-
// If finally is not present, we should mark pipelinerun as
859-
// failed so that no further execution happens. Also,
860-
// this will set the completion time of the pipelineRun.
861-
// NewPermanentError should also be returned so that
862-
// reconcilation stops here
863-
pr.Status.MarkFailed(v1.PipelineRunReasonInvalidTaskResultReference.String(), err.Error())
864-
return controller.NewPermanentError(err)
865-
}
866857
}
867858
}
868859
// GetFinalTasks only returns final tasks when a DAG is complete

pkg/reconciler/pipelinerun/pipelinerun_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ status:
12901290
image: busybox
12911291
script: 'exit 0'
12921292
conditions:
1293-
- message: "Invalid task result reference: Could not find result with name result2 for task task1"
1294-
reason: InvalidTaskResultReference
1293+
- message: "Tasks Completed: 2 (Failed: 1, Cancelled 0), Skipped: 0"
1294+
reason: Failed
12951295
status: "False"
12961296
type: Succeeded
12971297
childReferences:
@@ -1307,15 +1307,15 @@ status:
13071307
prt := newPipelineRunTest(t, d)
13081308
defer prt.Cancel()
13091309

1310-
reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-missing-results", []string{}, true)
1310+
reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-missing-results", []string{}, false)
13111311
if reconciledRun.Status.CompletionTime == nil {
13121312
t.Errorf("Expected a CompletionTime on invalid PipelineRun but was nil")
13131313
}
13141314

1315-
// The PipelineRun should be marked as failed due to InvalidTaskResultReference.
1315+
// The PipelineRun should be marked as failed
13161316
if d := cmp.Diff(expectedPipelineRun, reconciledRun, ignoreResourceVersion, ignoreLastTransitionTime, ignoreTypeMeta,
13171317
ignoreStartTime, ignoreCompletionTime, ignoreProvenance); d != "" {
1318-
t.Errorf("Expected to see PipelineRun run marked as failed with the reason: InvalidTaskResultReference. Diff %s", diff.PrintWantGot(d))
1318+
t.Errorf("Expected to see PipelineRun run marked as failed. Diff %s", diff.PrintWantGot(d))
13191319
}
13201320

13211321
// Check that the expected TaskRun was created

pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (t *ResolvedPipelineTask) skip(facts *PipelineRunFacts) TaskSkipStatus {
349349
var skippingReason v1.SkippingReason
350350

351351
switch {
352-
case facts.isFinalTask(t.PipelineTask.Name) || t.isScheduled():
352+
case facts.isFinalTask(t.PipelineTask.Name) || t.isScheduled() || t.isValidationFailed(facts.ValidationFailedTask):
353353
skippingReason = v1.None
354354
case facts.IsStopping():
355355
skippingReason = v1.StoppingSkip

pkg/reconciler/pipelinerun/resources/pipelinerunstate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ func (state PipelineRunState) getNextTasks(candidateTasks sets.String) []*Resolv
364364
func (facts *PipelineRunFacts) IsStopping() bool {
365365
for _, t := range facts.State {
366366
if facts.isDAGTask(t.PipelineTask.Name) {
367-
if t.isFailure() && t.PipelineTask.OnError != v1.PipelineTaskContinue {
367+
if (t.isFailure() || t.isValidationFailed(facts.ValidationFailedTask)) && t.PipelineTask.OnError != v1.PipelineTaskContinue {
368368
return true
369369
}
370370
}

0 commit comments

Comments
 (0)