Skip to content

[Backport release-1.5] fix(kubernetes): make node group resources optional when instanceType is set - #3156

Merged
myasnikovdaniil merged 1 commit into
release-1.5from
backport-3121-to-release-1.5
Jul 3, 2026
Merged

[Backport release-1.5] fix(kubernetes): make node group resources optional when instanceType is set#3156
myasnikovdaniil merged 1 commit into
release-1.5from
backport-3121-to-release-1.5

Conversation

@myasnikovdaniil

Copy link
Copy Markdown
Contributor

What this PR does

Backport of #3121 to release-1.5.

Makes node group resources optional, so a node group sized purely by instanceType (with resources omitted) passes values.schema.json validation and installs. When a group sets both instanceType and explicit resources (both cpu and memory), 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 overriding domain.cpu/memory. A partial spec (only one of cpu/memory) alongside an instanceType fails fast at render time.

Cherry-picked from a349c753; conflicts resolved against the release-1.5 tree (the management-cluster Talos worker bootstrap stack present on main is not on this branch, so the schema/template/test layout differ). Generated files (values.schema.json, README.md, cozyrds, API types) regenerated with make generate to match. helm unittest passes (134 tests), including the four new node-group sizing cases adapted to this branch's document layout.

Release note

fix(kubernetes): make node group resources optional when instanceType is set

…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)
@github-actions github-actions Bot added area/kubernetes Issues or PRs related to the tenant Kubernetes app area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files labels Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 883f51e9-6545-49a0-9009-156959e09218

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backport-3121-to-release-1.5

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dosubot dosubot Bot added the backport Should change be backported on previous release label Jun 30, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 instanceType, the system gains more flexibility in resource allocation. The changes include logic to handle the precedence of explicit resources over instance types and strict validation to ensure consistent resource definitions, thereby improving the reliability of the Kubernetes cluster deployment process.

Highlights

  • Optional Node Group Resources: Modified the NodeGroup configuration to make resources optional, allowing node groups to be sized exclusively by instanceType.
  • Resource Precedence: Implemented logic where explicit resources (CPU and memory) take precedence over instanceType when both are provided, ensuring KubeVirt compatibility.
  • Validation Improvements: Added render-time validation to ensure that if resources are provided, both cpu and memory must be set, preventing partial specifications that would fail at admission.
  • Documentation and Testing: Updated values.schema.json, README.md, and values.yaml to reflect the changes and added comprehensive helm unittest cases to verify the new sizing behavior.
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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment Gemini (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)) }}

@myasnikovdaniil
myasnikovdaniil merged commit e441b2d into release-1.5 Jul 3, 2026
12 checks passed
@myasnikovdaniil
myasnikovdaniil deleted the backport-3121-to-release-1.5 branch July 3, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubernetes Issues or PRs related to the tenant Kubernetes app area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) backport Should change be backported on previous release kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants