Skip to content

Commit

Permalink
Merge pull request #10913 from torchiaf/10905-vgpu-ids-2-9
Browse files Browse the repository at this point in the history
Assign vGpu id when assigning vGpus to Harvester Cluster
  • Loading branch information
torchiaf committed May 2, 2024
2 parents 01219b7 + 7b09fe6 commit 703836f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
25 changes: 22 additions & 3 deletions pkg/harvester-manager/machine-config/harvester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ export default {
this.networksObj = JSON.parse(this.value.networkInfo);
this.networksHistoric = this.value.networkInfo;
this.getEnabledVGpuDevices();
this.update();
} catch (e) {
this.errors = exceptionToErrorsArray(e);
Expand Down Expand Up @@ -389,6 +391,7 @@ export default {
networkDataIsBase64,
vmAffinityIsBase64,
SOURCE_TYPE,
vGpuEnabledDevices: {},
vGpus,
};
},
Expand Down Expand Up @@ -700,9 +703,9 @@ export default {
async getVmImage() {
try {
const clusterId = get(this.credential, 'decodedData.clusterId');
const url = `/k8s/clusters/${ clusterId }/v1`;
if (url) {
if (clusterId) {
const url = `/k8s/clusters/${ clusterId }/v1`;
const res = await this.$store.dispatch('cluster/request', { url: `${ url }/${ HCI.IMAGE }s` });
this.images = res?.data;
Expand All @@ -712,6 +715,22 @@ export default {
}
},
async getEnabledVGpuDevices() {
const clusterId = get(this.credential, 'decodedData.clusterId');
if (clusterId) {
const url = `/k8s/clusters/${ clusterId }/v1`;
const res = await this.$store.dispatch('cluster/request', { url: `${ url }/${ HCI.VGPU_DEVICE }s` });
this.vGpuEnabledDevices = (res?.data || [])
.filter((v) => v.spec.enabled)
.reduce((acc, v) => ({
...acc,
[`${ VGPU_PREFIX.NVIDIA }${ v.spec.vGPUTypeName.replace(' ', '_') }`]: v.id
}), {});
}
},
removeAffinityUnusedFields(data) {
for (const key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
Expand Down Expand Up @@ -872,7 +891,7 @@ export default {
const vGPURequests = this.vGpus?.filter((name) => name).reduce((acc, deviceName, i) => ([
...acc,
{
name: `vgpu${ i + 1 }`,
name: this.vGpuEnabledDevices[deviceName] || `vgpu${ i + 1 }`,
deviceName
}
])
Expand Down
1 change: 1 addition & 0 deletions shell/config/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export const HCI = {
CLUSTER: 'harvesterhci.io.management.cluster',
DASHBOARD: 'harvesterhci.io.dashboard',
IMAGE: 'harvesterhci.io.virtualmachineimage',
VGPU_DEVICE: 'devices.harvesterhci.io.vgpudevice',
SETTING: 'harvesterhci.io.setting',
HARVESTER_CONFIG: 'rke-machine-config.cattle.io.harvesterconfig',
};
Expand Down

0 comments on commit 703836f

Please sign in to comment.