Skip to content

Commit

Permalink
fix(controller): Fix estimation bug. Fixes argoproj#4386 (argoproj#4396)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec committed Oct 27, 2020
1 parent bdac65b commit 7ace8f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions workflow/controller/estimation/estimator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package estimation

import (
"strings"

wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
)

Expand All @@ -26,10 +28,6 @@ func (e *estimator) EstimateNodeDuration(nodeName string) wfv1.EstimatedDuration
if e.baselineWF == nil {
return 0
}
// special case for root node
if nodeName == e.wf.Name {
nodeName = e.baselineWF.Name
}
oldNodeID := e.baselineWF.NodeID(nodeName)
oldNodeID := e.baselineWF.NodeID(strings.Replace(nodeName, e.wf.Name, e.baselineWF.Name, 1))
return wfv1.NewEstimatedDuration(e.baselineWF.Status.Nodes[oldNodeID].GetDuration())
}
10 changes: 6 additions & 4 deletions workflow/controller/estimation/estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func Test_estimator(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "my-wf"},
Status: wfv1.WorkflowStatus{
Nodes: map[string]wfv1.NodeStatus{
"my-wf": {StartedAt: a, FinishedAt: a},
"my-wy-873244444": {StartedAt: a, FinishedAt: a},
"my-wf": {StartedAt: a, FinishedAt: a},
"my-wy-873244444": {StartedAt: a, FinishedAt: a},
"my-wy-873244444.x": {StartedAt: a, FinishedAt: a},
},
},
},
Expand All @@ -29,8 +30,9 @@ func Test_estimator(t *testing.T) {
StartedAt: a,
FinishedAt: b,
Nodes: map[string]wfv1.NodeStatus{
"my-baseline": {StartedAt: a, FinishedAt: b},
"my-baseline-873244444": {StartedAt: a, FinishedAt: b},
"my-baseline": {StartedAt: a, FinishedAt: b},
"my-baseline-873244444": {StartedAt: a, FinishedAt: b},
"my-baseline-873244444.x": {StartedAt: a, FinishedAt: b},
},
},
},
Expand Down

0 comments on commit 7ace8f8

Please sign in to comment.