Skip to content

Commit

Permalink
fix(controller): Updates GetTaskAncestry to skip visited nod. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneRelax authored Mar 24, 2020
1 parent 183a29e commit e5bd6a7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions workflow/common/ancestry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ func GetTaskAncestry(ctx Context, taskName string, tasks []wfv1.DAGTask) []strin
for _, task := range tasks {
taskByName[task.Name] = task
}

visitedFlag := make(map[string]bool)
visited := make(map[string]time.Time)
var getAncestry func(s string)
getAncestry = func(currTask string) {
task := taskByName[currTask]
for _, depTask := range task.Dependencies {
getAncestry(depTask)
}
if currTask != taskName {
if _, ok := visited[currTask]; !ok {
visited[currTask] = getTimeFinished(ctx, currTask)
if !visitedFlag[currTask] {
task := taskByName[currTask]
for _, depTask := range task.Dependencies {
getAncestry(depTask)
}
if currTask != taskName {
if _, ok := visited[currTask]; !ok {
visited[currTask] = getTimeFinished(ctx, currTask)
}
}
visitedFlag[currTask] = true
}

}
getAncestry(taskName)

Expand Down

0 comments on commit e5bd6a7

Please sign in to comment.