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: Differentiate between Fulfilled and Completed #3083

Merged
merged 8 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/argo/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import (
"strings"
"text/tabwriter"

workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/pkg/errors"
"github.com/argoproj/pkg/humanize"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"sigs.k8s.io/yaml"

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

"github.com/argoproj/argo/cmd/argo/commands/client"
"github.com/argoproj/argo/util/printer"
"github.com/argoproj/argo/workflow/util"
Expand Down
18 changes: 15 additions & 3 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,11 +1189,17 @@ func (n Nodes) GetResourcesDuration() ResourcesDuration {
return i
}

// Completed returns whether a phase is completed, i.e. it finished execution or was skipped
func (phase NodePhase) Completed() bool {
return phase.Executed() || phase == NodeSkipped
}

// Executed returns whether or not a phase finished executing.
// Mainly, a skipped phase is not considered as having executed.
func (phase NodePhase) Executed() bool {
return phase == NodeSucceeded ||
phase == NodeFailed ||
phase == NodeError ||
phase == NodeSkipped
phase == NodeError
}

// Completed returns whether or not the workflow has completed execution
Expand All @@ -1219,11 +1225,17 @@ func (ws WorkflowStatus) FinishTime() *metav1.Time {
return &ws.FinishedAt
}

// Completed returns whether or not the node has completed execution
// Completed returns whether or not a node is completed, i.e. it finished execution or was skipped
func (n NodeStatus) Completed() bool {
return n.Phase.Completed() || n.IsDaemoned() && n.Phase != NodePending
}

// Completed returns whether or not the node finished executing
// Mainly, a Skipped node is not considered as having executed
func (n NodeStatus) Executed() bool {
return n.Phase.Executed()
}

func (in *WorkflowStatus) AnyActiveSuspendNode() bool {
return in.Nodes.Any(func(node NodeStatus) bool { return node.IsActiveSuspendNode() })
}
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (woc *wfOperationCtx) executeDAGTask(dagCtx *dagContext, taskName string) {

node := dagCtx.getTaskNode(taskName)
task := dagCtx.GetTask(taskName)
if node != nil && node.Completed() {
if node != nil && node.Executed() {
// Run the node's onExit node, if any.
hasOnExitNode, onExitNode, err := woc.runOnExitNode(task.Name, task.OnExit, dagCtx.boundaryID, dagCtx.tmplCtx)
if hasOnExitNode && (onExitNode == nil || !onExitNode.Completed() || err != nil) {
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (woc *wfOperationCtx) executeStepGroup(stepGroup []wfv1.WorkflowStep, sgNod
step := nodeSteps[childNode.Name]
if !childNode.Completed() {
completed = false
} else {
} else if childNode.Executed() {
hasOnExitNode, onExitNode, err := woc.runOnExitNode(step.Name, step.OnExit, stepsCtx.boundaryID, stepsCtx.tmplCtx)
if hasOnExitNode && (onExitNode == nil || !onExitNode.Completed() || err != nil) {
// The onExit node is either not complete or has errored out, return.
Expand Down