diff --git a/pkg/harvester-manager/machine-config/harvester.vue b/pkg/harvester-manager/machine-config/harvester.vue index bfbce4847ce..bc1a941e774 100644 --- a/pkg/harvester-manager/machine-config/harvester.vue +++ b/pkg/harvester-manager/machine-config/harvester.vue @@ -376,7 +376,7 @@ export default { if (this.value.vgpuInfo) { const vGPURequests = JSON.parse(this.value.vgpuInfo)?.vGPURequests; - vGpus = vGPURequests?.map((r) => r?.name).filter((r) => r) || []; + vGpus = vGPURequests?.map((r) => r?.deviceName).filter((f) => f) || []; } return { @@ -482,10 +482,14 @@ export default { }, vGpuOptions() { - return uniq([ + const vGpuTypes = uniq([ ...this.vGpusInit, - ...Object.keys(this.vGpuDevices).filter((k) => this.vGpuDevices[k].enabled && this.vGpuDevices[k].allocatable > 0), + ...Object.values(this.vGpuDevices) + .filter((vGpu) => vGpu.enabled && vGpu.allocatable > 0 && !!vGpu.type) + .map((vGpu) => vGpu.type), ]); + + return vGpuTypes } }, @@ -884,15 +888,18 @@ export default { }, updateVGpu() { - const vGPURequests = this.vGpus?.filter((name) => name).reduce((acc, name) => ([ - ...acc, - { - name, - deviceName: this.vGpuDevices[name]?.type, - } - ]), []); + /** + * We are assigning the first vGpu profile found for each vGpu type selected by the user. + * This will not work if we will remove the limit of only one vGpu assignable to each cluster. + */ + const vGPURequests = this.vGpus?.filter((f) => f).map((deviceName) => ({ + name: Object.values(this.vGpuDevices).filter((f) => f.type === deviceName)?.[0]?.id || '', + deviceName, + })) || []; this.value.vgpuInfo = vGPURequests.length > 0 ? JSON.stringify({ vGPURequests }) : ''; + + console.log(this.value.vgpuInfo) }, addCloudConfigComment(value) { @@ -1091,18 +1098,6 @@ export default { }, vGpuOptionLabel(opt) { - const vGpu = this.vGpuDevices[opt]; - - if (vGpu) { - let label = `${ vGpu.type?.replace(VGPU_PREFIX.NVIDIA, '') } - ${ vGpu.id }`; - - if (vGpu.allocatable > 0) { - label += ` (allocatable: ${ vGpu.allocatable })`; - } - - return label; - } - return opt; } }