feat(recipes): render value-aware Kustomize templates - #13125
Conversation
WalkthroughChangesThe Kustomize matrix generator now supports value-aware Jinja templates, strict sandboxed rendering, base-resource lookup, generated Component materialization, stale-file cleanup, and validation. AWS EFA recipe overlays now use shared instance-type templates and generated Components. Kustomize template generation
Estimated code review effort: 4 (Complex) | ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@recipes/qwen3-235b-a22b-fp8/README.md`:
- Around line 66-70: Update the contributor regeneration instruction near the
existing `unfold` and `render` guidance to explicitly include shared template
sources alongside recipe-local Components and shared Components. Ensure
contributors are told to run both regeneration steps after editing a template,
while preserving the existing generated-artifact editing guidance.
In `@recipes/qwen3-32b/vllm/cloud-providers/README.md`:
- Around line 69-73: Update the regeneration commands in the README to reference
recipes/qwen3-32b/vllm/cloud-providers/.kustomize-matrix.yaml instead of
.kustomize-matrix.yaml for both unfold and render, while preserving the existing
command structure.
In `@tests/test_kustomize_matrix.py`:
- Around line 187-189: Add a pytest timeout marker to
test_unfold_materializes_template_component_with_base_and_variant_values, using
the repository’s established timeout-marker convention and a suitable limit for
its two run_matrix subprocesses and kustomize build.
- Around line 283-289: Update the subprocess invocation in the test build to use
the existing kustomize_command() helper instead of the bare "kustomize"
executable, while preserving the current overlay path, output capture, and
return-code assertion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0433d04d-c43f-4746-b656-e2758ab0470e
📒 Files selected for processing (31)
.github/workflows/pre-merge.ymlrecipes/AGENTS.mdrecipes/CONTRIBUTING.mdrecipes/kustomize/components/aws-efa-p16d16/kustomization.yamlrecipes/kustomize/components/aws-efa-p16d16/patch-dgd.yamlrecipes/kustomize/components/aws-efa-p8d16/kustomization.yamlrecipes/kustomize/components/aws-efa-p8d16/patch-dgd.yamlrecipes/kustomize/components/aws-efa-p8d8/kustomization.yamlrecipes/kustomize/components/aws-efa-p8d8/patch-dgd.yamlrecipes/kustomize/templates/aws-efa/p5.48xlarge/kustomization.yaml.j2recipes/kustomize/templates/aws-efa/p5.48xlarge/values.yamlrecipes/kustomize/templates/aws-efa/p6-b200.48xlarge/kustomization.yaml.j2recipes/kustomize/templates/aws-efa/p6-b200.48xlarge/values.yamlrecipes/qwen3-235b-a22b-fp8/README.mdrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/.kustomize-matrix.yamlrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/deploy-aws-p6-b200.48xlarge.yamlrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/kustomize/overlays/aws-p6-b200.48xlarge/generated-components/00-aws-efa-p6-b200.48xlarge/kustomization.yamlrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/kustomize/overlays/aws-p6-b200.48xlarge/kustomization.yamlrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/kustomize/overlays/gcp-roce/kustomization.yamlrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/kustomize/overlays/generic/kustomization.yamlrecipes/qwen3-235b-a22b-fp8/trtllm/disagg/blackwell/kustomize/overlays/nscale-ib/kustomization.yamlrecipes/qwen3-32b/vllm/cloud-providers/.kustomize-matrix.yamlrecipes/qwen3-32b/vllm/cloud-providers/README.mdrecipes/qwen3-32b/vllm/cloud-providers/kustomize/overlays/aks-ib/kustomization.yamlrecipes/qwen3-32b/vllm/cloud-providers/kustomize/overlays/aws-p5.48xlarge/generated-components/00-aws-efa-p5.48xlarge/kustomization.yamlrecipes/qwen3-32b/vllm/cloud-providers/kustomize/overlays/aws-p5.48xlarge/kustomization.yamlrecipes/qwen3-32b/vllm/cloud-providers/kustomize/overlays/gke-roce/kustomization.yamlrecipes/qwen3-32b/vllm/cloud-providers/kustomize/overlays/nebius-ib/kustomization.yamlrecipes/qwen3-32b/vllm/cloud-providers/kustomize/overlays/nscale-ib/kustomization.yamlscripts/kustomize-matrix.pytests/test_kustomize_matrix.py
💤 Files with no reviewable changes (6)
- recipes/kustomize/components/aws-efa-p8d8/kustomization.yaml
- recipes/kustomize/components/aws-efa-p8d16/kustomization.yaml
- recipes/kustomize/components/aws-efa-p8d16/patch-dgd.yaml
- recipes/kustomize/components/aws-efa-p16d16/patch-dgd.yaml
- recipes/kustomize/components/aws-efa-p8d8/patch-dgd.yaml
- recipes/kustomize/components/aws-efa-p16d16/kustomization.yaml
|
🔄 Datadog auto-retried 1 job - 1 passed on retry 🎯 Code Coverage (details) 🔗 Commit SHA: 9bb03a9 | Docs | Datadog PR Page | Give us feedback! |
02e445e to
1e9c181
Compare
|
Instead of duplicating the Jinja template across instance types, we should have a base Jinja template that allow a recipe matrix to select an instance directory, it will supply a local values and optional custom component logic while sharing the parent Jinja template across instance types. Matrix file templates:
- source: ../../../kustomize/templates/aws-efa/p5.48xlarge
path: components/efaGenerated component structured for an inherited P5 template example: The root generated Component is a wrapper: apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
components:
- base
- instance # present only when the instance layer existsWe should also Keep the shared Jinja template focused on calculating EFA resource requests. It must not select |
3ded9b3 to
3aa3e78
Compare
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
3aa3e78 to
3cc55e9
Compare
|
/ok to test 56e7a94 |
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
jh-nv
left a comment
There was a problem hiding this comment.
Thanks.
There is a concern of removing newly generated components, please take a look
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
|
/ok to test 4f6ce8f |
|
Summary
sourceand an overlay-relativepath.base.<kind>[name]), and template defaults overridden by matrix values.kustomize/overlays/<variant>/components/<name>/, so users need neither Python nor Jinja.aws-efa-p8d8,aws-efa-p8d16, andaws-efa-p16d16Components with AWS instance-type selections. P5 adds its instance-affinity patch while P6 uses the family defaults.disagg-workers/aws-efaComponent directly and remove the redundantcomponents/aws-efawrapper.Closes #13109.
Template model
A recipe matrix selects a concrete source and the public Component path:
The selected directory and exactly its direct parent form the template bundle:
Resolution is deterministic:
*.yamland*.yaml.j2files provide defaults..j2determines that output name. Childx.yamltherefore replaces parentx.yaml.j2, and childx.yaml.j2replaces parentx.yaml.values.yamlmappings are merged parent, selected directory, then matrix; later values win.There is no
.kustomize-template.yaml, recursive inheritance, inferred Kustomize layer, or Python merge of Kustomize YAML. A template needing layers declares normal Kustomizecomponents,resources, orpatchesin its files.Both static
kustomization.yamland renderedkustomization.yaml.j2are accepted. The result must be one normal KustomizeComponent. External Kustomize paths are rebased from the source file that declared them.unfoldmaterializes the P5 selection as a flat, hand-written-looking Component:P5 replaces the family Kustomization to add instance affinity and retains the inherited EFA resource patch. P6 is values-only and inherits both family YAML files. The P5 final manifest matches Erez's proposed recipe output; P6 remains unchanged.
Template context
Before rendering, the generator runs
kustomize buildfor the matrix source. Every resulting resource is available by lowercase kind and name:The generic
onlyfilter requires exactly one resource of a kind. Templates can use arithmetic, loops, and conditionals againstbaseandvalues;StrictUndefinedturns missing inputs into generation errors. No provider-, DGD-, or worker-specific values are synthesized in Python.Generated YAML files include a contributor warning and runnable regeneration command. Final
deploy-*.yamlfiles preserve ordinary Base comments at their corresponding positions while omitting nested generated-file metadata comments.User workflow
Users consume the checked-in artifacts directly. They do not run
unfoldorrender:They can also write their own
kustomization.yamlfrom the checked-in Base and Components, or compose an ad hoc overlay with:Contributor workflow
Contributors edit the matrix, Base, static Components, and template sources. From the repository root, regenerate checked-in public overlays first and rendered manifests second:
unfold --checkand the repository-widecheckcommand compare expected output without overwriting contributor files.unfold --cleanremoves obsolete generated Components after template paths or variants move.The Recipe Check CI job runs:
It validates generated template Components, public overlays, rendered manifests, stale artifacts, and the central OpenAPI schema generated from the operator CRDs.
Validation
pre-commit run --files <changed files>uv run --no-project --with 'pytest>=8.0' --with 'jinja2==3.1.6' --with 'pyyaml>=6.0' --with 'pydantic>=2' --with 'pytest-asyncio>=1.0' --with 'pytest-benchmark>=4' python3 -m pytest --noconftest tests/test_kustomize_matrix.py tests/test_generate_kustomize_openapi.py(15 passed)scripts/kustomize-matrix.py check