Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ vGPU implementation - follow-ups #3101

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apis/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,21 @@ type PCIDeviceSpec struct {
// virtual machine is cloned.
// Mutually exclusive with VGPUProfile as VGPUProfile and DeviceID + VendorID
// are two independent ways to define PCI devices.
// +kubebuilder:validation:Required
// +optional
DeviceID *int32 `json:"deviceId,omitempty"`
// VendorId is the vendor ID of a virtual machine's PCI, in integer.
// Defaults to the eponymous property value in the template from which the
// virtual machine is cloned.
// Mutually exclusive with VGPUProfile as VGPUProfile and DeviceID + VendorID
// are two independent ways to define PCI devices.
// +kubebuilder:validation:Required
// +optional
VendorID *int32 `json:"vendorId,omitempty"`
// VGPUProfile is the profile name of a virtual machine's vGPU, in string.
// Defaults to the eponymous property value in the template from which the
// virtual machine is cloned.
// Mutually exclusive with DeviceID and VendorID as VGPUProfile and DeviceID + VendorID
// are two independent ways to define PCI devices.
// +kubebuilder:validation:Required
// +optional
Copy link
Member

Choose a reason for hiding this comment

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

makes sense

Copy link
Member Author

Choose a reason for hiding this comment

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

I was confused at first why the field was not required in the CRD, but then I realized that omitempty overwrites the explicit marker..

Copy link
Member

@neolit123 neolit123 Jul 10, 2024

Choose a reason for hiding this comment

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

what made sense to me is that deviceID + vendorID are mut.ex. with VGPUProfile, if i remember the original PR logic correctly. so we cannot have them all as required.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, having them all as optional and then having validation in the webhook definitely makes sense

VGPUProfile string `json:"vGPUProfile,omitempty"`
// CustomLabel is the hardware label of a virtual machine's PCI device.
// Defaults to the eponymous property value in the template from which the
Expand Down
5 changes: 2 additions & 3 deletions docs/gpu-vgpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ We are using NVIDIA Tesla V100 32GB cards for this example and will use the `gri
### Create the cluster template

```shell
$ make dev-flavors
go run ./packaging/flavorgen --output-dir /home/user/.cluster-api/overrides/infrastructure-vsphere/v0.0.0
$ make release-flavors
```

Edit the generated Cluster template (`cluster-template.yaml`) to set the values for the `pciDevices` array. Here we are editing the VSphereMachineTemplate object for the worker nodes. This will create a worker node with a single NVIDIA 16GB vGPU device attached to the VM.
Edit the generated Cluster template (e.g. `out/cluster-template.yaml`) to set the values for the `pciDevices` array. Here we are editing the VSphereMachineTemplate object for the worker nodes. This will create a worker node with a single NVIDIA 16GB vGPU device attached to the VM.

```yaml
---
Expand Down
2 changes: 1 addition & 1 deletion internal/webhooks/vspheremachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func validatePCIDevices(devices []infrav1.PCIDeviceSpec) field.ErrorList {
// Valid case for PCI Passthrough.
continue
}
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "template", "spec", "pciDevices", fmt.Sprintf("%d", i)), device, "should have either deviceId + vendorId or vGPUProfile set"))
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "template", "spec", "pciDevices").Index(i), device, "should have either deviceId + vendorId or vGPUProfile set"))
}
return allErrs
}
Loading