From 6cb9fac72d470b7f16672802ea4627ba9d887c29 Mon Sep 17 00:00:00 2001 From: Simon Behar Date: Mon, 22 Mar 2021 12:10:34 -0700 Subject: [PATCH] split Signed-off-by: Simon Behar --- cmd/argo/commands/get.go | 8 ++++++-- workflow/controller/dag.go | 4 ++-- workflow/controller/steps.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/argo/commands/get.go b/cmd/argo/commands/get.go index 00b52e3fe3da..794331f91ec9 100644 --- a/cmd/argo/commands/get.go +++ b/cmd/argo/commands/get.go @@ -352,13 +352,14 @@ func convertToRenderTrees(wf *wfv1.Workflow) map[string]renderNode { // Used to store children of a boundary node that has not been parsed yet // Maps boundary Node name -> array of render Children parentBoundaryMap := make(map[string][]renderNode) - // Used to store Non Boundary Parent nodes so render children can attach // Maps non Boundary Parent Node name -> *nonBoundaryParentNode nonBoundaryParentMap := make(map[string]*nonBoundaryParentNode) // Used to store children which have a Non Boundary Parent from rendering perspective // Maps non Boundary render Children name -> *nonBoundaryParentNode nonBoundaryParentChildrenMap := make(map[string]*nonBoundaryParentNode) + // A node is a boundary node if any other node references it in its own node.boundaryID field. + isBoundaryNodeMap := make(map[string]bool) // We have to do a 2 pass approach because anything that is a child // of a nonBoundaryParent and also has a boundaryID we may not know which @@ -371,6 +372,9 @@ func convertToRenderTrees(wf *wfv1.Workflow) map[string]renderNode { log.Fatal("Missing node type in status node. Cannot get workflows created with Argo <= 2.0 using the default or wide output option.") return nil } + + isBoundaryNodeMap[status.BoundaryID] = true + if isNonBoundaryParentNode(status.Type) { n := nonBoundaryParentNode{nodeInfo: nodeInfo{id: id}} nonBoundaryParentMap[id] = &n @@ -384,7 +388,7 @@ func convertToRenderTrees(wf *wfv1.Workflow) map[string]renderNode { // 2nd Pass process everything for id, status := range wf.Status.Nodes { switch { - case isBoundaryNode(status.Type): + case isBoundaryNode(status.Type) || isBoundaryNodeMap[status.ID]: n := boundaryNode{nodeInfo: nodeInfo{id: id}} boundaryNodeMap[id] = &n // Attach to my parent if needed diff --git a/workflow/controller/dag.go b/workflow/controller/dag.go index ee7d1e0de232..ae0edbd49972 100644 --- a/workflow/controller/dag.go +++ b/workflow/controller/dag.go @@ -253,7 +253,7 @@ func (woc *wfOperationCtx) executeDAG(ctx context.Context, nodeName string, tmpl if taskNode.Completed() { // Run the node's onExit node, if any. Since this is a target task, we don't need to consider the status // of the onExit node before continuing. That will be done in assesDAGPhase - _, _, err := woc.runOnExitNode(ctx, dagCtx.GetTask(taskName).OnExit, taskName, taskNode.Name, dagCtx.boundaryID, dagCtx.tmplCtx) + _, _, err := woc.runOnExitNode(ctx, dagCtx.GetTask(taskName).OnExit, taskName, taskNode.Name, taskNode.ID, dagCtx.tmplCtx) if err != nil { return node, err } @@ -342,7 +342,7 @@ func (woc *wfOperationCtx) executeDAGTask(ctx context.Context, dagCtx *dagContex if node.Completed() { // Run the node's onExit node, if any. - hasOnExitNode, onExitNode, err := woc.runOnExitNode(ctx, task.OnExit, task.Name, node.Name, dagCtx.boundaryID, dagCtx.tmplCtx) + hasOnExitNode, onExitNode, err := woc.runOnExitNode(ctx, task.OnExit, task.Name, node.Name, node.ID, dagCtx.tmplCtx) if hasOnExitNode && (onExitNode == nil || !onExitNode.Fulfilled() || err != nil) { // The onExit node is either not complete or has errored out, return. return diff --git a/workflow/controller/steps.go b/workflow/controller/steps.go index 03c551d8baf2..cd7d314f60b4 100644 --- a/workflow/controller/steps.go +++ b/workflow/controller/steps.go @@ -260,7 +260,7 @@ func (woc *wfOperationCtx) executeStepGroup(ctx context.Context, stepGroup []wfv if !childNode.Fulfilled() { completed = false } else if childNode.Completed() { - hasOnExitNode, onExitNode, err := woc.runOnExitNode(ctx, step.OnExit, step.Name, childNode.Name, stepsCtx.boundaryID, stepsCtx.tmplCtx) + hasOnExitNode, onExitNode, err := woc.runOnExitNode(ctx, step.OnExit, step.Name, childNode.Name, childNodeID, stepsCtx.tmplCtx) if hasOnExitNode && (onExitNode == nil || !onExitNode.Fulfilled() || err != nil) { // The onExit node is either not complete or has errored out, return. completed = false