Skip to content

Commit

Permalink
NAS-128601: Allow removing all GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanY147 committed Oct 15, 2024
1 parent beaafba commit 978adc4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/pages/vm/vm-edit-form/vm-edit-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class VmEditFormComponent implements OnInit {
gpuOptions$ = this.gpuService.getGpuOptions();

readonly helptext = helptextVmWizard;
previouslySetGpuPciIds: string[] = [];

constructor(
private formBuilder: FormBuilder,
Expand Down Expand Up @@ -173,10 +174,13 @@ export class VmEditFormComponent implements OnInit {
])),
);
} else {
updateVmRequest$ = forkJoin([
const requests$: Observable<unknown>[] = [
this.ws.call('vm.update', [this.existingVm.id, vmPayload as VirtualMachineUpdate]),
this.vmGpuService.updateVmGpus(this.existingVm, []),
]);
];
if (this.previouslySetGpuPciIds.length) {
requests$.push(this.vmGpuService.updateVmGpus(this.existingVm, []));
}
updateVmRequest$ = forkJoin(requests$);
}

updateVmRequest$.pipe(untilDestroyed(this)).subscribe({
Expand All @@ -203,6 +207,7 @@ export class VmEditFormComponent implements OnInit {
const vmGpus = allGpus.filter(byVmPciSlots(vmPciSlots));

const vmGpuPciSlots = vmGpus.map((gpu) => gpu.addr.pci_slot);
this.previouslySetGpuPciIds = vmGpuPciSlots;
this.form.controls.gpus.setValue(vmGpuPciSlots, { emitEvent: false });
});
}
Expand Down

0 comments on commit 978adc4

Please sign in to comment.