diff --git a/workflow/util/util.go b/workflow/util/util.go index 8de93f916fb8..26e3f960f279 100644 --- a/workflow/util/util.go +++ b/workflow/util/util.go @@ -840,7 +840,6 @@ func newWorkflowsDag(wf *wfv1.Workflow) ([]*node, error) { // create mapping from node to parent // as well as creating temp mappings from nodeID to node for _, wfNode := range wf.Status.Nodes { - wfNode := wfNode n := node{} n.n = &wfNode nodes[wfNode.ID] = &n @@ -850,7 +849,6 @@ func newWorkflowsDag(wf *wfv1.Workflow) ([]*node, error) { } for _, wfNode := range wf.Status.Nodes { - wfNode := wfNode parentWfNode, ok := parentsMap[wfNode.ID] if !ok && wfNode.Name != wf.Name && !strings.HasPrefix(wfNode.Name, wf.ObjectMeta.Name+".onExit") { return nil, fmt.Errorf("couldn't find parent node for %s", wfNode.ID) @@ -1081,7 +1079,6 @@ func resetPath(isOnExitNode bool, onExitNodeName string, allNodes []*node, toNod return nil, nil, fmt.Errorf("must find %s but reached the root node", mustFind) } - err = nil switch mustFind { case wfv1.NodeTypePod: curr, err = consumePod(curr, addToReset, addToDelete) @@ -1150,10 +1147,7 @@ func dagSortedNodes(nodes []*node, rootNodeName string) []*node { curr := queue[0] sortedNodes = append(sortedNodes, curr) queue = queue[1:] - - for i := range curr.children { - queue = append(queue, curr.children[i]) - } + queue = append(queue, curr.children...) } return sortedNodes diff --git a/workflow/util/util_test.go b/workflow/util/util_test.go index cf10e382005e..0725747791c7 100644 --- a/workflow/util/util_test.go +++ b/workflow/util/util_test.go @@ -1859,8 +1859,8 @@ func TestRetryWorkflowWithNestedDAGsWithSuspendNodes(t *testing.T) { // Retry top individual pod node wf, podsToDelete, err := FormulateRetryWorkflow(ctx, wf, true, "name=fail-two-nested-dag-suspend.dag1-step1", nil) require.NoError(t, err) - assert.Equal(t, 1, len(wf.Status.Nodes)) - assert.Equal(t, 6, len(podsToDelete)) + assert.Len(t, wf.Status.Nodes, 1) + assert.Len(t, podsToDelete, 6) // Retry top individual suspend node wf = wfv1.MustUnmarshalWorkflow(retryWorkflowWithNestedDAGsWithSuspendNodes) @@ -1931,6 +1931,7 @@ func TestRetryWorkflowWithNestedDAGsWithSuspendNodes(t *testing.T) { // Retry the second individual node (pod node) connecting to the second DAG in one of the branches wf = wfv1.MustUnmarshalWorkflow(retryWorkflowWithNestedDAGsWithSuspendNodes) wf, podsToDelete, err = FormulateRetryWorkflow(ctx, wf, true, "name=fail-two-nested-dag-suspend.dag1-step3-middle2.dag2-branch2-step1.dag3-step2", nil) + require.NoError(t, err) assert.Len(t, wf.Status.Nodes, 12) assert.Equal(t, wfv1.NodeRunning, wf.Status.Nodes["fail-two-nested-dag-suspend"].Phase) assert.Equal(t, wfv1.NodeSucceeded, wf.Status.Nodes.FindByName("fail-two-nested-dag-suspend.dag1-step1").Phase)