Skip to content

Commit

Permalink
fix: Deleted pods are not tracked correctly when retrying workflow (#…
Browse files Browse the repository at this point in the history
…9340)

Signed-off-by: Yuan Tang <[email protected]>

Signed-off-by: Yuan Tang <[email protected]>
  • Loading branch information
terrytangyuan authored Aug 11, 2022
1 parent e12c697 commit b430180
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,15 @@ func getDescendantNodeIDs(wf *wfv1.Workflow, node wfv1.NodeStatus) []string {
return descendantNodeIDs
}

func deletePodNodeDuringRetryWorkflow(wf *wfv1.Workflow, node wfv1.NodeStatus, deletedPods map[string]bool, podsToDelete []string) []string {
func deletePodNodeDuringRetryWorkflow(wf *wfv1.Workflow, node wfv1.NodeStatus, deletedPods map[string]bool, podsToDelete []string) (map[string]bool, []string) {

This comment has been minimized.

Copy link
@smile-luobin

smile-luobin Aug 12, 2022

Contributor

i think map deletedPods no need to return.
both map and slice are passed-by-reference.
reference of slice podToDelete is modified by append in function, so we need to return.

templateName := getTemplateFromNode(node)
version := GetWorkflowPodNameVersion(wf)
podName := PodName(wf.Name, node.Name, templateName, node.ID, version)
if _, ok := deletedPods[podName]; !ok {
deletedPods[podName] = true
podsToDelete = append(podsToDelete, podName)
}
return podsToDelete
return deletedPods, podsToDelete
}

// FormulateRetryWorkflow formulates a previous workflow to be retried, deleting all failed steps as well as the onExit node (and children)
Expand Down Expand Up @@ -866,14 +866,14 @@ func FormulateRetryWorkflow(ctx context.Context, wf *wfv1.Workflow, restartSucce

if node.Type == wfv1.NodeTypePod {
deletedNodes[node.ID] = true
podsToDelete = deletePodNodeDuringRetryWorkflow(wf, node, deletedPods, podsToDelete)
deletedPods, podsToDelete = deletePodNodeDuringRetryWorkflow(wf, node, deletedPods, podsToDelete)

descendantNodeIDs := getDescendantNodeIDs(wf, node)
for _, descendantNodeID := range descendantNodeIDs {
deletedNodes[descendantNodeID] = true
descendantNode := wf.Status.Nodes[descendantNodeID]
if descendantNode.Type == wfv1.NodeTypePod {
podsToDelete = deletePodNodeDuringRetryWorkflow(wf, descendantNode, deletedPods, podsToDelete)
deletedPods, podsToDelete = deletePodNodeDuringRetryWorkflow(wf, descendantNode, deletedPods, podsToDelete)
}
}
} else if node.Name == wf.ObjectMeta.Name {
Expand Down

0 comments on commit b430180

Please sign in to comment.