Skip to content

Commit

Permalink
Re-enable machine pools validation
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Aug 9, 2024
1 parent 578e44d commit 7d8d4d4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/harvester-manager/machine-config/harvester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ export default {
this.validatorDiskAndNetowrk(errors);
this.validatorVGpus(errors);
podAffinityValidator(this.vmAffinity.affinity, this.$store.getters, errors);
return { errors };
Expand Down Expand Up @@ -676,6 +678,38 @@ export default {
}
},
validatorVGpus(errors) {
const notAllocatable = this.vGpus
.map((type) => {
const allocated = this.machinePools.reduce((acc, machinePool) => {
const vGPURequests = JSON.parse(machinePool?.config?.vgpuInfo || '')?.vGPURequests;
const vGpuTypes = vGPURequests?.map((r) => r?.deviceName).filter((f) => f) || [];
if (vGpuTypes.includes(type)) {
return acc + machinePool.pool.quantity;
}
return acc;
}, 0);
return {
vGpu: Object.values(this.vGpuDevices).filter((f) => f.type === type)?.[0],
allocated
}

Check warning on line 699 in pkg/harvester-manager/machine-config/harvester.vue

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
})
.filter(({ vGpu, allocated }) => vGpu && vGpu.allocatable > 0 && vGpu.allocatable < allocated);
notAllocatable.forEach(({ vGpu, allocated }) => {
const message = this.$store.getters['i18n/t']('cluster.credential.harvester.vGpus.errors.notAllocatable', {
vGpu: vGpu?.type,

Check warning on line 705 in pkg/harvester-manager/machine-config/harvester.vue

View workflow job for this annotation

GitHub Actions / lint

Missing space before value for key 'vGpu'
allocated,
allocatable: vGpu?.allocatable
});
errors.push(message);

Check warning on line 709 in pkg/harvester-manager/machine-config/harvester.vue

View workflow job for this annotation

GitHub Actions / lint

Expected blank line before this statement
});
},
valuesChanged(value, type) {
this.value[type] = base64Encode(value);
},
Expand Down
3 changes: 3 additions & 0 deletions shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ cluster:
networkName: Network Name
macAddress: Mac Address
macFormat: 'Invalid MAC address format.'
vGpus:
errors:
notAllocatable: '[{vGpu}] vGPU device is not allocatable; required: {allocated}, allocatable: {allocatable}'
volume:
title: Volumes
volume: Volume
Expand Down

0 comments on commit 7d8d4d4

Please sign in to comment.