forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(controller): Track N/M progress. See argoproj#2717 (argoproj#4194)
- Loading branch information
Showing
24 changed files
with
325 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Workflow Progress | ||
|
||
![alpha](assets/alpha.svg) | ||
|
||
> v2.12 and after | ||
When you run a workflow, the controller will report on its progress. | ||
|
||
We define progress as two numbers, `N/M` such that `0 <= N <= M and 0 <= M <= 1`. | ||
|
||
* `N` is the number of completed tasks. | ||
* `M` is the total number of tasks. | ||
|
||
E.g. `0/0`, `0/1` or `50/100`. | ||
|
||
Unlike [estimated duration](estimated-duration.md), progress is deterministic. I.e. it will be the same for each workflow, regardless of any problems. | ||
|
||
Progress for each node is calculated as follows: | ||
|
||
2. For a pod node either `1/1` if completed or `0/1` otherwise. | ||
3. For non-leaf nodes, the sum of its children. | ||
|
||
For a whole workflow's, progress is the sum of all its leaf nodes. | ||
|
||
!!! Warning | ||
`M` will increase during workflow run each time a node is added to the graph. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// Progress in N/M format. N is number of task complete. M is number of tasks. | ||
type Progress string | ||
|
||
func NewProgress(n, m int64) (Progress, bool) { | ||
return ParseProgress(fmt.Sprintf("%v/%v", n, m)) | ||
} | ||
|
||
func ParseProgress(s string) (Progress, bool) { | ||
v := Progress(s) | ||
return v, v.IsValid() | ||
} | ||
|
||
func (in Progress) parts() []string { | ||
return strings.SplitN(string(in), "/", 2) | ||
} | ||
|
||
func (in Progress) N() int64 { | ||
return parseInt64(in.parts()[0]) | ||
} | ||
|
||
func (in Progress) M() int64 { | ||
return parseInt64(in.parts()[1]) | ||
} | ||
|
||
func (in Progress) Add(x Progress) Progress { | ||
return Progress(fmt.Sprintf("%v/%v", in.N()+x.N(), in.M()+x.M())) | ||
} | ||
|
||
func (in Progress) IsValid() bool { | ||
return in != "" && in.N() >= 0 && in.N() <= in.M() && in.M() > 0 | ||
} | ||
|
||
func parseInt64(s string) int64 { | ||
v, _ := strconv.ParseInt(s, 10, 64) | ||
return v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestProgress(t *testing.T) { | ||
t.Run("ParseProgress", func(t *testing.T) { | ||
_, ok := ParseProgress("") | ||
assert.False(t, ok) | ||
progress, ok := ParseProgress("0/1") | ||
assert.True(t, ok) | ||
assert.Equal(t, Progress("0/1"), progress) | ||
}) | ||
t.Run("IsValid", func(t *testing.T) { | ||
assert.False(t, Progress("").IsValid()) | ||
assert.False(t, Progress("/0").IsValid()) | ||
assert.False(t, Progress("0/").IsValid()) | ||
assert.False(t, Progress("0/0").IsValid()) | ||
assert.False(t, Progress("1/0").IsValid()) | ||
assert.True(t, Progress("0/1").IsValid()) | ||
}) | ||
t.Run("Add", func(t *testing.T) { | ||
assert.Equal(t, Progress("1/2"), Progress("0/0").Add("1/2")) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// +build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/suite" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" | ||
"github.com/argoproj/argo/test/e2e/fixtures" | ||
) | ||
|
||
type ProgressSuite struct { | ||
fixtures.E2ESuite | ||
} | ||
|
||
func (s *ProgressSuite) TestDefaultProgress() { | ||
s.Given(). | ||
Workflow("@testdata/basic-workflow.yaml"). | ||
When(). | ||
SubmitWorkflow(). | ||
WaitForWorkflow(). | ||
Then(). | ||
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) { | ||
assert.Equal(t, wfv1.NodeSucceeded, status.Phase) | ||
assert.Equal(t, wfv1.Progress("1/1"), status.Progress) | ||
assert.Equal(t, wfv1.Progress("1/1"), status.Nodes[metadata.Name].Progress) | ||
}) | ||
} | ||
|
||
func TestProgressSuite(t *testing.T) { | ||
suite.Run(t, new(ProgressSuite)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.