Skip to content

Commit

Permalink
fix: Move when condition to higher priority
Browse files Browse the repository at this point in the history
When using "when" condition in pipelinerun definition we can sometime
get into a situation when a task would be skipped due to "when"
condition but instead it is skipped either by parent is skipped or
result reference is missing. This behaviour has a negative impact on the
rest of the tasks in the pipeline.

A good example of this issue is represented by this pipeline:

A -> B -> C

In case B depends on A's result and both A and B uses when condition
that both evaluates to false the C is automatically skipped with
"Parent Tasks were skipped" even-though C doesn't depend on any previous
results.

With this change both A and B are skipped by evaluating the "when"
condition and C is executed as expected.

This commit address the bug #7680.

Signed-off-by: Ales Raszka <[email protected]>
  • Loading branch information
Allda committed Feb 17, 2025
1 parent 783c11a commit 584627a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ func (t *ResolvedPipelineTask) skip(facts *PipelineRunFacts) TaskSkipStatus {
skippingReason = v1.GracefullyCancelledSkip
case facts.IsGracefullyStopped():
skippingReason = v1.GracefullyStoppedSkip
case t.skipBecauseWhenExpressionsEvaluatedToFalse(facts):
skippingReason = v1.WhenExpressionsSkip
case t.skipBecauseParentTaskWasSkipped(facts):
skippingReason = v1.ParentTasksSkip
case t.skipBecauseResultReferencesAreMissing(facts):
skippingReason = v1.MissingResultsSkip
case t.skipBecauseWhenExpressionsEvaluatedToFalse(facts):
skippingReason = v1.WhenExpressionsSkip
case t.skipBecausePipelineRunPipelineTimeoutReached(facts):
skippingReason = v1.PipelineTimedOutSkip
case t.skipBecausePipelineRunTasksTimeoutReached(facts):
Expand Down

0 comments on commit 584627a

Please sign in to comment.