-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Store resolved templates #1552
Store resolved templates #1552
Changes from all commits
4bc6019
68effb5
ff9b537
06bb8dc
cd465b9
4e58a56
12a83a8
fcfd745
4d675e3
f9fa9a7
2303372
c3782a7
4560473
5750ac4
a70f342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,34 +186,29 @@ func (d *dagContext) hasMoreRetries(node *wfv1.NodeStatus) bool { | |
return true | ||
} | ||
// pick the first child to determine it's template type | ||
childNode := d.wf.Status.Nodes[node.Children[0]] | ||
tmpl, err := d.tmplCtx.GetTemplate(&childNode) | ||
if err != nil { | ||
childNode, ok := d.wf.Status.Nodes[node.Children[0]] | ||
if !ok { | ||
return false | ||
} | ||
if tmpl.RetryStrategy.Limit != nil && int32(len(node.Children)) > *tmpl.RetryStrategy.Limit { | ||
tmpl := d.wf.GetStoredOrLocalTemplate(&childNode) | ||
if tmpl != nil && tmpl.RetryStrategy != nil && tmpl.RetryStrategy.Limit != nil && int32(len(node.Children)) > *tmpl.RetryStrategy.Limit { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func (woc *wfOperationCtx) executeDAG(nodeName string, tmplCtx *templateresolution.Context, tmpl *wfv1.Template, orgTmpl wfv1.TemplateHolder, boundaryID string) *wfv1.NodeStatus { | ||
node := woc.getNodeByName(nodeName) | ||
if node != nil && node.Completed() { | ||
return node | ||
} | ||
if node == nil { | ||
node = woc.initializeNode(nodeName, wfv1.NodeTypeDAG, orgTmpl, boundaryID, wfv1.NodeRunning) | ||
} | ||
func (woc *wfOperationCtx) executeDAG(nodeName string, tmplCtx *templateresolution.Context, tmpl *wfv1.Template, boundaryID string) error { | ||
node := woc.markNodePhase(nodeName, wfv1.NodeRunning) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the logic has been changed to unconditionally mark this node as Running. Previously, executeDAG was a NO-OP when the dag node was already considered completed. The new logic means we will flap back to running no matter what and go through re-assessment logic. I'd like to understand the reason for this change since it seems like we should never flap back to running. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the logic and node completions are checked at the beginning of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know |
||
|
||
defer func() { | ||
if node != nil && woc.wf.Status.Nodes[node.ID].Completed() { | ||
if woc.wf.Status.Nodes[node.ID].Completed() { | ||
_ = woc.killDaemonedChildren(node.ID) | ||
} | ||
}() | ||
|
||
dagCtx := &dagContext{ | ||
boundaryName: nodeName, | ||
boundaryID: woc.wf.NodeID(nodeName), | ||
boundaryID: node.ID, | ||
tasks: tmpl.DAG.Tasks, | ||
visited: make(map[string]bool), | ||
tmpl: tmpl, | ||
|
@@ -238,9 +233,10 @@ func (woc *wfOperationCtx) executeDAG(nodeName string, tmplCtx *templateresoluti | |
dagPhase := dagCtx.assessDAGPhase(targetTasks, woc.wf.Status.Nodes) | ||
switch dagPhase { | ||
case wfv1.NodeRunning: | ||
return woc.getNodeByName(nodeName) | ||
return nil | ||
case wfv1.NodeError, wfv1.NodeFailed: | ||
return woc.markNodePhase(nodeName, dagPhase) | ||
_ = woc.markNodePhase(nodeName, dagPhase) | ||
return nil | ||
} | ||
|
||
// set outputs from tasks in order for DAG templates to support outputs | ||
|
@@ -258,7 +254,7 @@ func (woc *wfOperationCtx) executeDAG(nodeName string, tmplCtx *templateresoluti | |
} | ||
outputs, err := getTemplateOutputsFromScope(tmpl, &scope) | ||
if err != nil { | ||
return woc.markNodeError(nodeName, err) | ||
return err | ||
} | ||
if outputs != nil { | ||
node = woc.getNodeByName(nodeName) | ||
|
@@ -267,7 +263,6 @@ func (woc *wfOperationCtx) executeDAG(nodeName string, tmplCtx *templateresoluti | |
} | ||
|
||
// set the outbound nodes from the target tasks | ||
node = woc.getNodeByName(nodeName) | ||
outbound := make([]string, 0) | ||
for _, depName := range targetTasks { | ||
depNode := dagCtx.GetTaskNode(depName) | ||
|
@@ -278,10 +273,12 @@ func (woc *wfOperationCtx) executeDAG(nodeName string, tmplCtx *templateresoluti | |
outbound = append(outbound, outboundNodeIDs...) | ||
} | ||
woc.log.Infof("Outbound nodes of %s set to %s", node.ID, outbound) | ||
node = woc.getNodeByName(nodeName) | ||
node.OutboundNodes = outbound | ||
woc.wf.Status.Nodes[node.ID] = *node | ||
|
||
return woc.markNodePhase(nodeName, wfv1.NodeSucceeded) | ||
_ = woc.markNodePhase(nodeName, wfv1.NodeSucceeded) | ||
return nil | ||
} | ||
|
||
// executeDAGTask traverses and executes the upward chain of dependencies of a task | ||
|
@@ -437,6 +434,9 @@ func (woc *wfOperationCtx) resolveDependencyReferences(dagCtx *dagContext, task | |
ancestors := common.GetTaskAncestry(dagCtx, task.Name, dagCtx.tasks) | ||
for _, ancestor := range ancestors { | ||
ancestorNode := dagCtx.GetTaskNode(ancestor) | ||
if ancestorNode == nil { | ||
return nil, errors.InternalErrorf("Ancestor task node %s not found", ancestor) | ||
} | ||
prefix := fmt.Sprintf("tasks.%s", ancestor) | ||
if ancestorNode.Type == wfv1.NodeTypeTaskGroup { | ||
var ancestorNodes []wfv1.NodeStatus | ||
|
@@ -445,11 +445,11 @@ func (woc *wfOperationCtx) resolveDependencyReferences(dagCtx *dagContext, task | |
ancestorNodes = append(ancestorNodes, node) | ||
} | ||
} | ||
tmpl, err := dagCtx.tmplCtx.GetTemplate(ancestorNode) | ||
if err != nil { | ||
return nil, errors.InternalWrapError(err) | ||
tmpl := dagCtx.wf.GetStoredOrLocalTemplate(ancestorNode) | ||
if tmpl != nil { | ||
return nil, errors.InternalErrorf("Template of ancestor node '%s' not found", ancestorNode.Name) | ||
} | ||
err = woc.processAggregateNodeOutputs(tmpl, &scope, prefix, ancestorNodes) | ||
err := woc.processAggregateNodeOutputs(tmpl, &scope, prefix, ancestorNodes) | ||
if err != nil { | ||
return nil, errors.InternalWrapError(err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a trade-off. If we store used local templates in
StoredTemplates
as well, we can remove the conditional fromGetStoredTemplate
and make the code simpler.