From 584627a5214afd6d520c93a60c161c48eb245d4a Mon Sep 17 00:00:00 2001 From: Ales Raszka Date: Mon, 17 Feb 2025 14:59:43 +0100 Subject: [PATCH] fix: Move when condition to higher priority 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 --- pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index a0f8180f770..d70ac23c200 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -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):