diff --git a/pkg/reconciler/pipeline/dag/dag.go b/pkg/reconciler/pipeline/dag/dag.go index 16f39fc4fce..d632aec0d98 100644 --- a/pkg/reconciler/pipeline/dag/dag.go +++ b/pkg/reconciler/pipeline/dag/dag.go @@ -128,7 +128,7 @@ func linkPipelineTasks(prev *Node, next *Node) error { // Check if we are adding cycles. visited := map[string]bool{prev.Task.HashKey(): true, next.Task.HashKey(): true} path := []string{next.Task.HashKey(), prev.Task.HashKey()} - if err := visit(next.Task.HashKey(), prev.Prev, path, visited); err != nil { + if err := visit(prev.Prev, path, visited); err != nil { return fmt.Errorf("cycle detected: %w", err) } next.Prev = append(next.Prev, prev) @@ -136,18 +136,13 @@ func linkPipelineTasks(prev *Node, next *Node) error { return nil } -func visit(currentName string, nodes []*Node, path []string, visited map[string]bool) error { - var sb strings.Builder +func visit(nodes []*Node, path []string, visited map[string]bool) error { for _, n := range nodes { path = append(path, n.Task.HashKey()) if _, ok := visited[n.Task.HashKey()]; ok { return errors.New(getVisitedPath(path)) } - sb.WriteString(currentName) - sb.WriteByte('.') - sb.WriteString(n.Task.HashKey()) - visited[sb.String()] = true - if err := visit(n.Task.HashKey(), n.Prev, path, visited); err != nil { + if err := visit(n.Prev, path, visited); err != nil { return err } }