Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: find correct retry node when using templateRef. Fixes: #12633 #12683

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions workflow/controller/retry_tweak.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@ type RetryTweak = func(retryStrategy wfv1.RetryStrategy, nodes wfv1.Nodes, pod *
func FindRetryNode(nodes wfv1.Nodes, nodeID string) *wfv1.NodeStatus {
boundaryID := nodes[nodeID].BoundaryID
boundaryNode := nodes[boundaryID]
templateName := boundaryNode.TemplateName
for _, node := range nodes {
if node.Type == wfv1.NodeTypeRetry && node.TemplateName == templateName {
return &node
if boundaryNode.TemplateName != "" {
templateName := boundaryNode.TemplateName
for _, node := range nodes {
if node.Type == wfv1.NodeTypeRetry && node.TemplateName == templateName {
return &node
}
}
}
if boundaryNode.TemplateRef != nil {
templateRef := boundaryNode.TemplateRef
for _, node := range nodes {
if node.Type == wfv1.NodeTypeRetry && node.TemplateRef != nil && node.TemplateRef.Name == templateRef.Name && node.TemplateRef.Template == templateRef.Template {
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
return &node
}
}
}

return nil
}

Expand Down
23 changes: 23 additions & 0 deletions workflow/controller/retry_tweak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ func TestFindRetryNode(t *testing.T) {
Children: []string{},
TemplateName: "tmpl2",
},
"E1": wfv1.NodeStatus{
ID: "E1",
Type: wfv1.NodeTypeRetry,
Phase: wfv1.NodeRunning,
BoundaryID: "A1",
Children: []string{},
TemplateRef: &wfv1.TemplateRef{
Name: "tmpl1",
Template: "tmpl3",
},
},
"E2": wfv1.NodeStatus{
ID: "E2",
Type: wfv1.NodeTypePod,
Phase: wfv1.NodeRunning,
BoundaryID: "E1",
Children: []string{},
TemplateName: "tmpl2",
},
}
t.Run("Expect to find retry node", func(t *testing.T) {
node := allNodes["B2"]
Expand All @@ -68,4 +87,8 @@ func TestFindRetryNode(t *testing.T) {
a := FindRetryNode(allNodes, "A1")
assert.Nil(t, a)
})
t.Run("Expect to find retry node has TemplateRef", func(t *testing.T) {
node := allNodes["E1"]
assert.Equal(t, FindRetryNode(allNodes, "E2"), &node)
})
}
Loading