Skip to content

[virtual-machine] Add GPU support - #766

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
vm-gpu
Apr 9, 2025
Merged

[virtual-machine] Add GPU support#766
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
vm-gpu

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Apr 7, 2025

Copy link
Copy Markdown
Member

Related issues to GPU feature:

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added GPU configuration support, enabling users to specify and attach GPU resources for virtual machine deployments.
  • Documentation
    • Updated setup instructions to include the new GPU parameter, assisting users in configuring additional hardware options.
  • Chores
    • Refreshed version information across the applications to align with the latest release.

@coderabbitai

coderabbitai Bot commented Apr 7, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates chart versioning for both virtual-machine and vm-instance applications and introduces GPU configuration. In the virtual-machine package, the chart’s version and appVersion have been bumped, and a conditional GPU block is added to the VM template. A new gpus parameter is also introduced in the values file. Similarly, the vm-instance package sees version bumps, the addition of a GPU configuration block (with a disk reference fix), documentation updates in the README, and the GPU property added to its schema.

Changes

File(s) Change Summary
packages/.../virtual-machine/Chart.yaml
packages/.../vm-instance/Chart.yaml
Updated chart version and appVersion fields: virtual-machine from 0.8.2 to 0.9.0 and vm-instance from 0.5.1 to 0.6.0 (with appVersion converted from string to integer).
packages/.../virtual-machine/values.yaml
packages/.../vm-instance/values.yaml
Added new gpus parameter (an empty array by default) with descriptive comments and an example entry for GPU configuration.
packages/.../virtual-machine/templates/vm.yaml
packages/.../vm-instance/templates/vm.yaml
Added a conditional block that injects a GPU devices list if .Values.gpus exists; in vm-instance, the disk name reference was also corrected from .name to $disk.name.
packages/.../vm-instance/README.md
packages/.../virtual-machine/README.md
Updated documentation to include details on the new gpus parameter in the virtual machine configuration.
packages/.../vm-instance/values.schema.json
packages/.../virtual-machine/values.schema.json
Added a new gpus property defined as an array of objects to the configuration schema.
packages/.../virtual-machine/Makefile
packages/.../vm-instance/Makefile
Added a command in the generate target to modify the values.schema.json for the gpus property.

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Config
    participant TE as Template Engine
    participant VM as Virtual Machine Spec
    
    U->>TE: Provide configuration values (including 'gpus')
    alt GPUs defined
        TE->>VM: Insert GPU devices block from .Values.gpus
    else
        TE->>VM: Render configuration without GPU details
    end
    VM-->>U: Return rendered VM manifest
Loading

Poem

I'm a jittery rabbit with a code-filled leap,
Hopping through YAML fields so deep.
Versions change with a nimble bound,
GPUs in the mix—a new trick is found!
My whiskers twitch with each clever tweak,
Celebrating changes in a hop unique!
🐇🌟


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5bdd0 and 9ad6b0d.

📒 Files selected for processing (12)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/Makefile (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/Makefile (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)

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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.

a bit of nitpicking :)

Comment thread packages/apps/vm-instance/README.md Outdated
| `instanceType` | Virtual Machine instance type | `u1.medium` |
| `instanceProfile` | Virtual Machine prefferences profile | `ubuntu` |
| `disks` | List of disks to attach | `[]` |
| `gpus` | List of gpus to attach | `[]` |

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.

Suggested change
| `gpus` | List of gpus to attach | `[]` |
| `gpus` | List of GPUs to attach | `[]` |

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks fixed

},
"gpus": {
"type": "array",
"description": "List of gpus to attach",

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.

Suggested change
"description": "List of gpus to attach",
"description": "List of GPUs to attach",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks fixed

@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 (1)
packages/apps/vm-instance/templates/vm.yaml (1)

52-53: Avoid Variable Shadowing in Disk Lookup

Within the disks loop, the lookup function reassigns the loop variable $disk—this can lead to shadowing and potential confusion. It is recommended to use a new variable name (e.g. $foundDisk) for the result of the lookup. For example:

-            {{- $disk := lookup "cdi.kubevirt.io/v1beta1" "DataVolume" $.Release.Namespace (printf "vm-disk-%s" $disk.name) }}
-            {{- if $disk }}
-            {{- if and (hasKey $disk.metadata.annotations "vm-disk.cozystack.io/optical") (eq (index $disk.metadata.annotations "vm-disk.cozystack.io/optical") "true") }}
-            cdrom: {}
-            {{- else }}
-            disk: {}
-            {{- end }}
-            {{- if eq $i 0 }}
-            bootOrder: 1
-            {{- end }}
-            {{- else }}
-            {{-   fail (printf "Specified disk not exists in cluster: %s" .name) }}
-            {{- end }}
+            {{- $foundDisk := lookup "cdi.kubevirt.io/v1beta1" "DataVolume" $.Release.Namespace (printf "vm-disk-%s" $disk.name) }}
+            {{- if $foundDisk }}
+            {{- if and (hasKey $foundDisk.metadata.annotations "vm-disk.cozystack.io/optical") (eq (index $foundDisk.metadata.annotations "vm-disk.cozystack.io/optical") "true") }}
+            cdrom: {}
+            {{- else }}
+            disk: {}
+            {{- end }}
+            {{- if eq $i 0 }}
+            bootOrder: 1
+            {{- end }}
+            {{- else }}
+            {{-   fail (printf "Specified disk not exists in cluster: %s" $disk.name) }}
+            {{- end }}

This change will avoid unintended shadowing and make the template clearer.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 49b5b51 and 0302307.

📒 Files selected for processing (8)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/templates/vm.yaml (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 comments (10)
packages/apps/vm-instance/values.schema.json (1)

148-155: Critical: Inconsistent GPU Definition in JSON Schema
The new "gpus" property is defined as an array of strings with a default value set as "[]". However, elsewhere the GPU configuration is expected to be provided as an object (with at least a name property), as shown by the example in the values file and its usage in the template (i.e. using {{ $gpu.name }}). This discrepancy could lead to validation or runtime errors. Consider updating the schema so that each item is defined as an object and the default value is an actual empty array rather than a string.

Example diff:

-"gpus": {
-  "type": "array",
-  "description": "List of gpus to attach",
-  "default": "[]",
-  "items": {
-    "type": "string"
-  }
-},
+"gpus": {
+  "type": "array",
+  "description": "List of gpus to attach",
+  "default": [],
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": { "type": "string" }
+    },
+    "required": ["name"]
+  }
+},

[flag_critical_issue][suggest_essential_refactor]

packages/apps/virtual-machine/values.yaml (1)

29-33: Approval: New GPU Parameter in Virtual Machine Values
The new GPU parameter is clearly documented with an example and is appropriately initialized as an empty array. Please ensure that GPU entries are provided as objects (with a name field) so that they align with how they are referenced in the template.
[approve_code_changes]

packages/apps/vm-instance/README.md (1)

47-49: Approval: Updated Documentation with GPU Parameter
The addition of the gpus parameter in the parameters table is clear and helpful. The documentation now properly reflects the new configuration option.
[approve_code_changes]

packages/apps/virtual-machine/templates/vm.yaml (1)

72-77: Critical: GPU Device Entry Structure Mismatch
The conditional block for GPUs correctly checks for .Values.gpus and iterates over it; however, it assumes that each GPU entry is an object with a name property ({{ $gpu.name }}). Please verify that the provided GPU configurations (and the JSON schema definition) match this structure. Adjustments in the schema or values may be needed if GPU entries are meant to be objects.
[flag_critical_issue][request_verification]

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

27-32: Approval: Clear GPU Parameter Configuration
The GPU parameter is added with a clear description and an example entry. The default of an empty array is appropriate. Just ensure that all parts of the system expect each GPU entry to be an object with a name property.
[approve_code_changes]

packages/apps/virtual-machine/Chart.yaml (2)

20-20: Chart Version Update Verification

The chart version has been updated from the previous version (0.8.2) to 0.9.0, which is consistent with the intended version bump.


26-26: App Version Type Consistency

The appVersion is now specified as an unquoted integer (0.9.0) rather than a string. Please verify that this change in data type is intentional and compatible with any downstream consumers of this chart.

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

20-20: Chart Version Bump

The chart version has been correctly updated from 0.5.1 to 0.6.0. This version bump aligns with the new GPU support and other feature changes.


26-26: App Version Update and Data Type Review

Similar to the virtual-machine chart, the appVersion is now an integer (0.6.0) rather than a quoted string. Confirm that this change does not adversely affect components that expect a string value.

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

44-49: Addition of GPU Configuration Block

A new GPU configuration block has been added inside the devices section. The conditional check (if .Values.gpus) and the iteration over each GPU to generate a device entry (- deviceName: {{ $gpu.name }}) look correct. Please verify that the resulting YAML indentation and formatting are as expected when rendered.

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

I double the proper capitalization by Nick Volynkin (@NickVolynkin) .

Also, the $disk change is minor, but is not related to the GPU. Should be submitted and tested separately.

@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: 1

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

50-50: New 'gpus' Parameter Documentation

The new gpus parameter is added to the parameters table with a default value of [] and a clear description. Consider adding an example usage or a brief note on how GPU identifiers should be specified—this could help users unfamiliar with GPU configuration.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0302307 and 4c5bdd0.

📒 Files selected for processing (10)
  • 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 (8)
  • packages/apps/virtual-machine/values.yaml
  • packages/apps/virtual-machine/templates/vm.yaml
  • packages/apps/vm-instance/values.schema.json
  • packages/apps/vm-instance/README.md
  • packages/apps/vm-instance/values.yaml
  • packages/apps/virtual-machine/Chart.yaml
  • packages/apps/vm-instance/templates/vm.yaml
  • packages/apps/vm-instance/Chart.yaml

Comment thread packages/apps/virtual-machine/values.schema.json Outdated
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
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