devantler-tech / devantler-tech/ksail
perf(workload): avoid double kustomization render for --include-crd-schemas rendered-CRD discovery
- Dominant language
- Go
- Stars
- 165
- Forks
- 12
- Avg merge
- 5h 41m
- Merged PRs (30d)
- 337
Description
> 🤖 Generated by the Daily AI Assistant
Part of #5906/#5344 (rendered-CRD-schema discovery, `--include-crd-schemas`, shipped in #5968).
## Problem
`addRenderedCRDSchemas` (in `pkg/cli/cmd/workload/validate.go`) renders every kustomization once to
discover CRDs present only in rendered Helm/Kustomize output, then the main validation pass renders
the same kustomizations again. `ChartCache` only memoizes repeat Helm templating, so the
kustomize/Flux expansion itself still runs twice per `validate` invocation when
`--include-crd-schemas` is set.
## Proposed direction
Thread the already-rendered manifest stream from the CRD-schema discovery pre-pass through to the
main validation pass (or vice versa) so `gitopsRenderer.expand` runs once per kustomization, not
twice, when the flag is enabled.
## Rough size
S–M — a plumbing change through `validate.go`, `findKustomizations`, and the renderer interface; no
behaviour change, covered by the existing `--include-crd-schemas` tests plus a render-count
regression test.
---
Flagged by CodeRabbit on #5968 (🏗️ Heavy lift / 🚀 Performance) — deferred out of that PR to keep its
diff focused; tracked here as a follow-up.
Contributor guide
Research direction
Start in pkg/cli/cmd/workload/validate.go, tracing addRenderedCRDSchemas, findKustomizations, and the renderer interface. Compare the discovery pre-pass with the main validation pass and identify how the rendered manifest stream can be reused. Done means gitopsRenderer.expand runs once per kustomization with --include-crd-schemas, existing flag tests pass, and a render-count regression test covers this behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100