fix(backend): detect circular component references and enforce reserved keywords in visitor.go. Fixes #13966 - #13967
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @bhuvan-somisetty. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
Hi @hbelmiro @jeffspahr @droctothorpe, Could you please review this backend compiler PR when you get a chance? This PR refactors Thanks! |
…ed keywords in visitor.go
Refactor pipelineDFS in backend/src/v2/compiler/visitor.go to maintain an active call-stack recursion set (inStack), preventing unhandled circular component references from emitting malformed Argo Workflows.
Enforces reserved RootComponentName ("root") check against user component names, enriches compiler error messages with task context, and eliminates redundant string conversions during proto unmarshaling.
Fixes kubeflow#13966
Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
a05b62b to
6cc5f52
Compare
|
/ok-to-test |
Description of your changes:
Problem
In
backend/src/v2/compiler/visitor.go, component dependency graphs are traversed using a depth-first search (pipelineDFS.dfs). Analysis of the compiler visitor pattern revealed multiple related defects:pipelineDFSused a single flatvisited map[string]boolmap. When a sub-DAG component referenced an ancestor component (circular dependency),if state.visited[name] { return nil }returnednilsilently. This allowed invalid cyclic pipeline specs to bypass API server validation and generate incomplete/corrupted Argo Workflow specs that failed with cryptic errors in Argo.rootComponent Name:RootComponentName("root") was not validated against user component names, allowing user components named"root"to collide with root DAG traversal state.GetPipelineSpecandGetDeploymentConfigperformed double JSON round-tripping (protojson.Marshal-> string ->protojson.Unmarshal), adding memory allocations during large pipeline compilation.Solution
inStack map[string]booltopipelineDFSto track active DFS recursion. IfinStack[name]is true,dfsreturns a clear cycle error (circular reference detected in component graph: <name>).RootComponentName("root") inAccept.task.GetTaskInfo().GetName()) and parent component name incomponentError.jsonByteseliminating intermediatestringconversions and buffer allocations.visitor_test.gocovering cycle detection, reserved keyword checks, and error message context.Fixes #13966
Checklist: