Skip to content

vms add sockets to resources - #1131

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
vms-add-socets-to-values-resources
Jul 2, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
vms-add-socets-to-values-resources

Conversation

@klinch0

@klinch0 klinch0 commented Jun 30, 2025 •

Copy link
Copy Markdown
Contributor

What this PR does

Release note

- Allow to set socket count for VM and VMI

Summary by CodeRabbit

  • New Features

    • Added support for specifying the number of CPU sockets (resources.sockets) in virtual machine configurations for both virtual-machine and vm-instance applications.
  • Documentation

    • Updated documentation to describe the new resources.sockets parameter and its role in defining vCPU topology.
  • Chores

    • Incremented chart versions for virtual-machine (to 0.12.0) and vm-instance (to 0.9.0).
    • Updated version mappings to reflect the latest releases.

@coderabbitai

coderabbitai Bot commented Jun 30, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

Andrei Kvapil (@kvaps) has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d089d95 and 70c7978.

📒 Files selected for processing (11)
  • packages/apps/versions_map (2 hunks)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/README.md (1 hunks)
  • packages/apps/virtual-machine/templates/vm.yaml (1 hunks)
  • packages/apps/virtual-machine/values.schema.json (1 hunks)
  • packages/apps/virtual-machine/values.yaml (1 hunks)
  • packages/apps/vm-instance/Chart.yaml (1 hunks)
  • packages/apps/vm-instance/README.md (1 hunks)
  • packages/apps/vm-instance/templates/vm.yaml (1 hunks)
  • packages/apps/vm-instance/values.schema.json (1 hunks)
  • packages/apps/vm-instance/values.yaml (1 hunks)

"""

Walkthrough

This change introduces a new resources.sockets parameter to both the virtual-machine and vm-instance Helm charts, allowing specification of CPU socket count for vCPU topology. Documentation, schema, templates, and default values are updated accordingly. Chart versions and version mappings are incremented to reflect these enhancements.

Changes

Files/Groups Change Summary
packages/apps/versions_map Updated HEAD pointers for virtual-machine and vm-instance to new versions and commit hashes.
packages/apps/virtual-machine/Chart.yaml
packages/apps/vm-instance/Chart.yaml
Incremented chart versions: virtual-machine (0.11.0→0.12.0), vm-instance (0.8.0→0.9.0).
packages/apps/virtual-machine/README.md
packages/apps/vm-instance/README.md
Added documentation for new resources.sockets parameter.
packages/apps/virtual-machine/templates/vm.yaml
packages/apps/vm-instance/templates/vm.yaml
Modified CPU config to conditionally include sockets alongside cores if both values are present.
packages/apps/virtual-machine/values.schema.json
packages/apps/vm-instance/values.schema.json
Added sockets property to the resources schema with description and default value.
packages/apps/virtual-machine/values.yaml
packages/apps/vm-instance/values.yaml
Added resources.sockets parameter with documentation and default value.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HelmChart
    participant VMTemplate

    User->>HelmChart: Provide values.yaml (including resources.cpu and resources.sockets)
    HelmChart->>VMTemplate: Render vm.yaml with provided values
    VMTemplate-->>HelmChart: If resources.cpu and resources.sockets are set, include both in CPU config
    HelmChart-->>User: Deploys VM with specified CPU cores and sockets
Loading

Possibly related PRs

  • cozystack/cozystack#430: Introduces the initial virtual-machine package, which this PR extends with new socket configuration.
  • cozystack/cozystack#569: Updates version hashes for virtual-machine and vm-instance, similar to the version mapping changes here.
  • cozystack/cozystack#776: Modifies version pointers for virtual-machine and vm-instance, directly related to version_map updates in this PR.

Suggested labels

enhancement, size:S

Suggested reviewers

  • klinch0

Poem

In the meadow of code, new sockets appear,
Giving VMs more shape, topology clear.
With charts now updated, and docs in tow,
The CPUs can flex, as the rabbits well know.
🐇✨
Version maps hop ahead,
As new features are spread!
"""


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@klinch0
klinch0 force-pushed the vms-add-socets-to-values-resources branch 2 times, most recently from 45c7584 to f71dee9 Compare June 30, 2025 07:32

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

♻️ Duplicate comments (2)
packages/apps/vm-instance/values.yaml (1)

33-40: Same integer-type consideration applies here

resources.sockets would benefit from being an integer rather than an empty string.

packages/apps/virtual-machine/values.schema.json (1)

188-192: Mirror the integer change for consistency

For parity with the previous comment, define sockets as an integer in this schema too.

🧹 Nitpick comments (4)
packages/apps/vm-instance/README.md (1)

39-55: Minor wording fixes in the parameters table

  • “passthrough” → “pass through” (verb form).
  • Sentence “Can be a single key or a list of keys.” lacks a subject.
-| `externalMethod`    | specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `PortList`  |
+| `externalMethod`    | Specify the method to pass through traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `PortList`  |
...
-| `sshKeys`           | List of SSH public keys for authentication. Can be a single key or a list of keys.                         | `[]`        |
+| `sshKeys`           | List of SSH public keys for authentication. It can be a single key or a list of keys.                      | `[]`        |
packages/apps/virtual-machine/README.md (1)

42-44: Same grammar nit: “pass through” is a verb

-| `externalMethod`          | specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `PortList`   |
+| `externalMethod`          | Specify the method to pass through traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `PortList`   |
packages/apps/virtual-machine/values.yaml (1)

35-42: Prefer integer type for resources.sockets

Unlike cpu/memory, sockets is a plain count. Defining it as an int (0 default) tightens validation and avoids string-to-int coercion later.

packages/apps/vm-instance/values.schema.json (1)

168-173: Schema could tighten validation by switching sockets to integer

Current definition (type: "string", default: "") allows non-numeric input. Using integer with minimum: 1 would catch user errors early.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78b4d06 and f71dee9.

📒 Files selected for processing (11)
  • packages/apps/versions_map (2 hunks)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/README.md (1 hunks)
  • packages/apps/virtual-machine/templates/vm.yaml (1 hunks)
  • packages/apps/virtual-machine/values.schema.json (1 hunks)
  • packages/apps/virtual-machine/values.yaml (1 hunks)
  • packages/apps/vm-instance/Chart.yaml (1 hunks)
  • packages/apps/vm-instance/README.md (1 hunks)
  • packages/apps/vm-instance/templates/vm.yaml (1 hunks)
  • packages/apps/vm-instance/values.schema.json (1 hunks)
  • packages/apps/vm-instance/values.yaml (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/apps/vm-instance/README.md

[grammar] ~42-~42: The word “passthrough” is a noun. The verb is spelled with a white space.
Context: ...externalMethod | specify method to passthrough the traffic to the virtual machine. All...

(NOUN_VERB_CONFUSION)


[style] ~52-~52: To form a complete sentence, be sure to include a subject or ‘there’.
Context: ... of SSH public keys for authentication. Can be a single key or a list of keys. ...

(MISSING_IT_THERE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (3)
packages/apps/virtual-machine/Chart.yaml (1)

20-20: Chart version bumped, but appVersion left unchanged – double-check intent

If the underlying VM application code (not just the chart templates) changed to support resources.sockets, consider incrementing appVersion as well.
Leaving appVersion: 0.11.0 is perfectly fine when only chart logic / manifests change, but please verify this is deliberate.

packages/apps/vm-instance/Chart.yaml (1)

20-20: Same note on appVersion consistency

version → 0.9.0 is correct.
Ensure the runtime application itself is still 0.8.0; otherwise bump appVersion too for clarity.

packages/apps/virtual-machine/README.md (1)

53-54: Great to see resources.sockets documented

Doc addition syncs with the chart change. ✅

Comment thread packages/apps/versions_map
Comment on lines +34 to 38
{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
cpu:
cores: {{ .Values.resources.cpu }}
sockets: {{ .Values.resources.sockets }}
{{- end }}

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.

🛠️ Refactor suggestion

⚠️ Potential issue

Breaking: CPU block now suppressed unless both cpu and sockets are set

Requiring .Values.resources.sockets as part of the and guard means existing charts that only specify resources.cpu will lose the entire cpu stanza, silently reverting to KubeVirt defaults.

-{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
-cpu:
-  cores: {{ .Values.resources.cpu }}
-  sockets: {{ .Values.resources.sockets }}
-{{- end }}
+{{- if or .Values.resources.cpu .Values.resources.sockets }}
+cpu:
+  {{- if .Values.resources.cpu }}
+  cores: {{ .Values.resources.cpu }}
+  {{- end }}
+  {{- if .Values.resources.sockets }}
+  sockets: {{ .Values.resources.sockets }}
+  {{- end }}
+{{- end }}

Restores backward-compatibility while still enabling socket topology.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
cpu:
cores: {{ .Values.resources.cpu }}
sockets: {{ .Values.resources.sockets }}
{{- end }}
{{- if or .Values.resources.cpu .Values.resources.sockets }}
cpu:
{{- if .Values.resources.cpu }}
cores: {{ .Values.resources.cpu }}
{{- end }}
{{- if .Values.resources.sockets }}
sockets: {{ .Values.resources.sockets }}
{{- end }}
{{- end }}
🤖 Prompt for AI Agents
In packages/apps/vm-instance/templates/vm.yaml around lines 34 to 38, the
current condition requires both .Values.resources.cpu and
.Values.resources.sockets to render the cpu block, which breaks backward
compatibility for charts specifying only cpu. Modify the condition to render the
cpu block if .Values.resources.cpu is set, and include sockets only if
.Values.resources.sockets is also set, so the cpu stanza is not suppressed when
sockets is missing.

Comment on lines +63 to 67
{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
cpu:
cores: {{ .Values.resources.cpu }}
sockets: {{ .Values.resources.sockets }}
{{- end }}

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.

💡 Verification agent

🧩 Analysis chain

cpu block now hard-requires sockets → breaks backward compatibility

The new guard

{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}

means that existing values files that specify only:

resources:
  cpu: 2

will no longer render a cpu: stanza at all. That is a silent breaking change for anyone upgrading the chart without adding the new key, and it also prevents the perfectly valid KubeVirt default (sockets defaults to 1 when omitted).

Recommend loosening the condition and making sockets optional:

-{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
+{{- if and .Values.resources .Values.resources.cpu }}
 cpu:
   cores: {{ .Values.resources.cpu }}
-  sockets: {{ .Values.resources.sockets }}
+  {{- if .Values.resources.sockets }}
+  sockets: {{ .Values.resources.sockets }}
+  {{- end }}
 {{- end }}

This preserves previous behaviour while allowing the new topology knob.

Please double-check that the default values.yaml actually sets resources.sockets; otherwise charts that relied only on cpu will break after upgrade. If you’d like, I can open a follow-up PR with the above patch.


🏁 Script executed:

#!/bin/bash
# Check default CPU and sockets settings in the chart's values.yaml
grep -R "resources:" -n packages/apps/virtual-machine/values.yaml -A5
grep -R "sockets" -n packages/apps/virtual-machine/values.yaml

Length of output: 446


Make sockets optional when rendering the cpu block to preserve backward compatibility

We’ve confirmed that packages/apps/virtual-machine/values.yaml defines:

resources:
  cpu: ""
  memory: ""
  sockets: ""

so users who set only resources.cpu (and rely on the default socket count) will currently see no cpu: stanza due to the extra .Values.resources.sockets guard. To restore the previous behavior (render cpu whenever cpu is set) while still allowing an explicit sockets override, update templates/vm.yaml as follows:

--- a/packages/apps/virtual-machine/templates/vm.yaml
+++ b/packages/apps/virtual-machine/templates/vm.yaml
@@ -63,7 +63,11 @@
-{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
+{{- if and .Values.resources .Values.resources.cpu }}
 cpu:
   cores: {{ .Values.resources.cpu }}
-  sockets: {{ .Values.resources.sockets }}
+  {{- if .Values.resources.sockets }}
+  sockets: {{ .Values.resources.sockets }}
+  {{- end }}
 {{- end }}

Locations needing this patch:

  • packages/apps/virtual-machine/templates/vm.yaml (around line 63)

This ensures:

  • Charts that specify only resources.cpu still render the cpu: block.
  • sockets is added only when explicitly provided (otherwise KubeVirt’s default of 1 socket applies).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
cpu:
cores: {{ .Values.resources.cpu }}
sockets: {{ .Values.resources.sockets }}
{{- end }}
{{- if and .Values.resources .Values.resources.cpu }}
cpu:
cores: {{ .Values.resources.cpu }}
{{- if .Values.resources.sockets }}
sockets: {{ .Values.resources.sockets }}
{{- end }}
{{- end }}
🤖 Prompt for AI Agents
In packages/apps/virtual-machine/templates/vm.yaml around lines 63 to 67, the
current condition requires both cpu and sockets to render the cpu block, which
breaks backward compatibility. Modify the condition to render the cpu block
whenever cpu is set, and include sockets only if it is explicitly provided. This
means checking for cpu alone to render the cpu block, and inside it,
conditionally add the sockets line only if sockets is set.

@kvaps
Andrei Kvapil (kvaps) force-pushed the vms-add-socets-to-values-resources branch 2 times, most recently from 032060f to d089d95 Compare July 2, 2025 11:24

@coderabbitai coderabbitai 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.

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/apps/vm-instance/README.md (3)

42-42: “pass through” is a verb phrase – fix wording for clarity

Use the verb phrase “pass through” (two words) instead of the noun “passthrough”.

-| `externalMethod`    | specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `PortList`  |
+| `externalMethod`    | Specify how to pass traffic through to the virtual machine. Allowed values: `WholeIP` and `PortList` | `PortList`  |

49-51: Document the coupling between resources.cpu and new resources.sockets

The chart template only renders the CPU topology when both resources.cpu and resources.sockets are set. Without mentioning this here, users may provide only one of the two values and wonder why nothing happens.

Consider amending the descriptions to make the dependency explicit, e.g.:

-| `resources.cpu`     | The number of CPU cores allocated to the virtual machine                                                   | `""`        |
-| `resources.sockets` | The number of CPU sockets allocated to the virtual machine (used to define vCPU topology)                  | `""`        |
+| `resources.cpu`     | The number of CPU cores allocated to the virtual machine (must be set together with `resources.sockets`)   | `""`        |
+| `resources.sockets` | The number of CPU sockets allocated to the virtual machine (defines vCPU topology; requires `resources.cpu`) | `""`        |

52-52: Complete the sentence for sshKeys row

The description lacks a subject. Small tweak improves readability.

-| `sshKeys`           | List of SSH public keys for authentication. Can be a single key or a list of keys.                         | `[]`        |
+| `sshKeys`           | List of SSH public keys for authentication. This can be a single key or a list of keys.                    | `[]`        |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f71dee9 and d089d95.

📒 Files selected for processing (11)
  • packages/apps/versions_map (2 hunks)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/README.md (1 hunks)
  • packages/apps/virtual-machine/templates/vm.yaml (1 hunks)
  • packages/apps/virtual-machine/values.schema.json (1 hunks)
  • packages/apps/virtual-machine/values.yaml (1 hunks)
  • packages/apps/vm-instance/Chart.yaml (1 hunks)
  • packages/apps/vm-instance/README.md (1 hunks)
  • packages/apps/vm-instance/templates/vm.yaml (1 hunks)
  • packages/apps/vm-instance/values.schema.json (1 hunks)
  • packages/apps/vm-instance/values.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/apps/vm-instance/Chart.yaml
  • packages/apps/vm-instance/templates/vm.yaml
  • packages/apps/virtual-machine/Chart.yaml
  • packages/apps/versions_map
  • packages/apps/vm-instance/values.yaml
  • packages/apps/virtual-machine/values.yaml
  • packages/apps/virtual-machine/README.md
  • packages/apps/virtual-machine/values.schema.json
  • packages/apps/vm-instance/values.schema.json
  • packages/apps/virtual-machine/templates/vm.yaml
🧰 Additional context used
🪛 LanguageTool
packages/apps/vm-instance/README.md

[grammar] ~42-~42: The word “passthrough” is a noun. The verb is spelled with a white space.
Context: ...externalMethod | specify method to passthrough the traffic to the virtual machine. All...

(NOUN_VERB_CONFUSION)


[style] ~52-~52: To form a complete sentence, be sure to include a subject or ‘there’.
Context: ... of SSH public keys for authentication. Can be a single key or a list of keys. ...

(MISSING_IT_THERE)

@kvaps
Andrei Kvapil (kvaps) force-pushed the vms-add-socets-to-values-resources branch from d089d95 to 70c7978 Compare July 2, 2025 12:17
@kvaps
Andrei Kvapil (kvaps) merged commit fb831c0 into main Jul 2, 2025
@kvaps
Andrei Kvapil (kvaps) deleted the vms-add-socets-to-values-resources branch July 2, 2025 14:33
Nick Volynkin (NickVolynkin) added a commit to cozystack/website that referenced this pull request Jul 3, 2025
Nick Volynkin (NickVolynkin) added a commit to cozystack/website that referenced this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants