Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't spawn new workflow child on abort
Browse files Browse the repository at this point in the history
If status check node aborted and has "abort with statuscheck" flag set,
don't spawn a new workflow child node for the next step.

This fixes a race condition where the serial reconciler spawns a new
child node in the window between the statuscheck node aborting and the
abort status being propagated to the parent.

Signed-off-by: Graham Brereton <graham.brereton@form3.tech>
grahambrereton-form3 committed Dec 12, 2023
1 parent 7a55558 commit c97f38c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/workflow/controllers/serial_node_reconciler.go
Original file line number Diff line number Diff line change
@@ -178,6 +178,15 @@ func (it *SerialNodeReconciler) syncChildNodes(ctx context.Context, node v1alpha
if err != nil {
return err
}

if abortedStatusCheck := findAbortedStatusCheckNode(finishedChildNodes); abortedStatusCheck != nil {
it.logger.Info(
"not spawning new child, status check node with status aborted and AbortWithStatusCheck = true",
"node",
fmt.Sprintf("%s/%s", abortedStatusCheck.Namespace, abortedStatusCheck.Name),
)
}

var taskToStartup string
if len(activeChildNodes) == 0 {
// no active children, trying to spawn a new one
@@ -287,3 +296,16 @@ func (it *SerialNodeReconciler) syncChildNodes(ctx context.Context, node v1alpha

return nil
}

func findAbortedStatusCheckNode(nodes []v1alpha1.WorkflowNode) *v1alpha1.WorkflowNode {
for _, node := range nodes {
if node.Spec.Type == v1alpha1.TypeStatusCheck && node.Spec.AbortWithStatusCheck {
for _, cond := range node.Status.Conditions {
if cond.Type == v1alpha1.ConditionAborted && cond.Status == corev1.ConditionTrue {
return &node
}
}
}
}
return nil
}

0 comments on commit c97f38c

Please sign in to comment.