Skip to content

Commit

Permalink
feat: simplifying
Browse files Browse the repository at this point in the history
Signed-off-by: MenD32 <[email protected]>
  • Loading branch information
MenD32 committed Oct 11, 2024
1 parent 15270a4 commit bce39fd
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ func (woc *wfOperationCtx) requeue() {

// processNodeRetries updates the retry node state based on the child node state and the retry strategy and returns the node.
func (woc *wfOperationCtx) processNodeRetries(node *wfv1.NodeStatus, retryStrategy wfv1.RetryStrategy, opts *executeTemplateOpts) (*wfv1.NodeStatus, bool, error) {
if node.Phase.Fulfilled() {
if node.Fulfilled() {
return node, true, nil
}

Expand All @@ -969,16 +969,11 @@ func (woc *wfOperationCtx) processNodeRetries(node *wfv1.NodeStatus, retryStrate
}

if !lastChildNode.Fulfilled() {
node.Daemoned = ptr.To(true)
return node, true, nil
}

if !lastChildNode.Phase.Fulfilled() {
// last child node is still running.
return node, true, nil
}

if (!lastChildNode.FailedOrError() && !lastChildNode.IsDaemoned()) || (lastChildNode.IsDaemoned() && !lastChildNode.Phase.Fulfilled()) {
if !lastChildNode.FailedOrError() {
node.Outputs = lastChildNode.Outputs.DeepCopy()
woc.wf.Status.Nodes.Set(node.ID, *node)
return woc.markNodePhase(node.Name, wfv1.NodeSucceeded), true, nil
Expand Down Expand Up @@ -2111,7 +2106,7 @@ func (woc *wfOperationCtx) executeTemplate(ctx context.Context, nodeName string,
childNodeIDs, lastChildNode := getChildNodeIdsAndLastRetriedNode(retryParentNode, woc.wf.Status.Nodes)

// The retry node might have completed by now.
if retryParentNode.Phase.Fulfilled() || (lastChildNode != nil && !lastChildNode.Phase.Fulfilled() && lastChildNode.IsDaemoned()) {
if retryParentNode.Fulfilled() && woc.childrenFulfilled(retryParentNode) {
// If retry node has completed, set the output of the last child node to its output.
// Runtime parameters (e.g., `status`, `resourceDuration`) in the output will be used to emit metrics.
if lastChildNode != nil {
Expand Down Expand Up @@ -2286,7 +2281,7 @@ func (woc *wfOperationCtx) executeTemplate(ctx context.Context, nodeName string,
}

func (woc *wfOperationCtx) handleNodeFulfilled(ctx context.Context, nodeName string, node *wfv1.NodeStatus, processedTmpl *wfv1.Template) *wfv1.NodeStatus {
if node == nil || !node.Phase.Fulfilled() {
if node == nil || !node.Phase.Fulfilled() || !woc.childrenFulfilled(node) {
return nil
}

Expand Down

0 comments on commit bce39fd

Please sign in to comment.