[Backport release-1.5] fix(kubernetes): make node group resources optional when instanceType is set - #3156
Conversation
…ver instanceType A node group is sized either by instanceType or by explicit resources, but the generated values schema required resources on every node group. A node group with instanceType and no resources — or an empty resources dropped during typed-CR to HelmRelease translation — failed schema validation with "missing property 'resources'" even though sizing was fully specified. Mark resources optional in the node group definition and regenerate the schema, API types, README, and ApplicationDefinition. The chart template emits domain.cpu/memory only when resources is present, so a node group sized purely by instanceType now passes validation and installs. When a node group sets both instanceType and explicit resources, explicit resources take precedence: the instancetype is omitted from the rendered VM and the per-group instancetype lookup is skipped, so KubeVirt accepts the explicit domain.cpu/memory with no instancetype to conflict with. instanceType stays required and defaulted (no schema change), so the console's required instanceType dropdown keeps working — sending the default instanceType plus explicit resources simply sizes the VM by resources. This replaces an earlier render-time hard failure on the both-set case, which was unreachable to clear from the dashboard (the required dropdown cannot be emptied). Explicit resources are all-or-nothing alongside an instanceType: a partial spec (only cpu, or only memory) on a group that carries a non-empty instanceType would emit one domain override next to the instancetype — which KubeVirt rejects — so it now fails at render time with a clear error. Partial resources on a group without an instanceType (used to tune kubelet reservations) are unaffected. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la> (cherry picked from commit a349c75)
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request backports changes from the main branch to the release-1.5 branch to make node group resources optional. By allowing node groups to be sized purely by Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request makes the resources field optional for Kubernetes node groups, allowing nodes to be sized either by instanceType or by explicit CPU and memory resources. When both are set, explicit resources take precedence and the instanceType is omitted to prevent KubeVirt validation failures. Additionally, validation is added to ensure both CPU and memory are set together or neither, along with comprehensive unit tests. A review comment suggests simplifying the partial resource specification check in cluster.yaml by removing the redundant instanceType guard, as a partial specification is always invalid regardless of whether instanceType is set.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| a clear render-time error instead of a late admission rejection. */}} | ||
| {{- $hasCpu := and $group.resources $group.resources.cpu }} | ||
| {{- $hasMem := and $group.resources $group.resources.memory }} | ||
| {{- if and $group.instanceType (or (and $hasCpu (not $hasMem)) (and $hasMem (not $hasCpu))) }} |
There was a problem hiding this comment.
A partial resource specification (setting only cpu or only memory) is always invalid, regardless of whether instanceType is set or not. If instanceType is empty or omitted, setting only one of them will still result in an invalid VM configuration that will be rejected by KubeVirt. We can simplify this check and make it more robust by removing the and $group.instanceType guard.
{{- if or (and $hasCpu (not $hasMem)) (and $hasMem (not $hasCpu)) }}
What this PR does
Backport of #3121 to
release-1.5.Makes node group
resourcesoptional, so a node group sized purely byinstanceType(withresourcesomitted) passesvalues.schema.jsonvalidation and installs. When a group sets bothinstanceTypeand explicitresources(bothcpuandmemory), the explicit resources take precedence: the instancetype is omitted from the rendered VM and the per-group instancetype lookup is skipped, so KubeVirt does not reject a VM that references an instancetype while overridingdomain.cpu/memory. A partial spec (only one ofcpu/memory) alongside aninstanceTypefails fast at render time.Cherry-picked from
a349c753; conflicts resolved against therelease-1.5tree (the management-cluster Talos worker bootstrap stack present onmainis not on this branch, so the schema/template/test layout differ). Generated files (values.schema.json,README.md, cozyrds, API types) regenerated withmake generateto match.helm unittestpasses (134 tests), including the four new node-group sizing cases adapted to this branch's document layout.Release note