Skip to content

Commit

Permalink
fix: http template doesn't update progress. Fixes #7239 (#7450)
Browse files Browse the repository at this point in the history
Signed-off-by: softwarebloat <nico.lino1991@gmail.com>
  • Loading branch information
softwarebloat authored Jan 6, 2022
1 parent e0f43b8 commit 3371e72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions workflow/progress/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func PodProgress(pod *apiv1.Pod, node *wfv1.NodeStatus) wfv1.Progress {
func UpdateProgress(wf *wfv1.Workflow) {
wf.Status.Progress = "0/0"
for _, node := range wf.Status.Nodes {
if node.Type != wfv1.NodeTypePod {
if node.Type != wfv1.NodeTypePod && node.Type != wfv1.NodeTypeHTTP {
continue
}
if node.Progress.IsValid() {
wf.Status.Progress = wf.Status.Progress.Add(node.Progress)
}
}
for nodeID, node := range wf.Status.Nodes {
if node.Type == wfv1.NodeTypePod {
if node.Type == wfv1.NodeTypePod && node.Type != wfv1.NodeTypeHTTP {
continue
}
progress := sumProgress(wf, node, make(map[string]bool))
Expand All @@ -60,7 +60,7 @@ func sumProgress(wf *wfv1.Workflow, node wfv1.NodeStatus, visited map[string]boo
// this will tolerate missing child (will be "") and therefore ignored
child := wf.Status.Nodes[childNodeID]
progress = progress.Add(sumProgress(wf, child, visited))
if child.Type == wfv1.NodeTypePod {
if child.Type == wfv1.NodeTypePod || child.Type == wfv1.NodeTypeHTTP {
v := child.Progress
if v.IsValid() {
progress = progress.Add(v)
Expand Down
19 changes: 19 additions & 0 deletions workflow/progress/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ func TestUpdater(t *testing.T) {
assert.Equal(t, wfv1.Progress("150/300"), wf.Status.Nodes["wf"].Progress)
assert.Equal(t, wfv1.Progress("150/300"), wf.Status.Progress)
}

func TestUpdaterWithHTTPNode(t *testing.T) {
ns := "my-ns"
wf := &wfv1.Workflow{
ObjectMeta: metav1.ObjectMeta{Namespace: ns, Name: "wf"},
Status: wfv1.WorkflowStatus{
Nodes: wfv1.Nodes{
"http": wfv1.NodeStatus{Phase: wfv1.NodeSucceeded, Type: wfv1.NodeTypeHTTP, Progress: wfv1.Progress("1/1")},
"wf": wfv1.NodeStatus{Children: []string{"http"}},
},
},
}

UpdateProgress(wf)

assert.Equal(t, wfv1.Progress("1/1"), wf.Status.Nodes["http"].Progress)
assert.Equal(t, wfv1.Progress("1/1"), wf.Status.Nodes["wf"].Progress)
assert.Equal(t, wfv1.Progress("1/1"), wf.Status.Progress)
}

0 comments on commit 3371e72

Please sign in to comment.