From 3f0155269c4d6fa12c53a4c5836adaec010f21c1 Mon Sep 17 00:00:00 2001 From: Marwan Ahmed Date: Tue, 25 Jan 2022 15:38:15 -0800 Subject: [PATCH] properly set FPGA capacity --- .../cloudprovider/azure/azure_template.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/azure/azure_template.go b/cluster-autoscaler/cloudprovider/azure/azure_template.go index 77e542d9f264..e55f5e32866e 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_template.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_template.go @@ -33,7 +33,10 @@ import ( "time" ) -const azureDiskTopologyKey string = "topology.disk.csi.azure.com/zone" +const ( + azureDiskTopologyKey = "topology.disk.csi.azure.com/zone" + xilinxFpgaResourceName = "xilinx.com/fpga-xilinx_u250_gen3x16_xdma_shell_2_1-0" +) func buildInstanceOS(template compute.VirtualMachineScaleSet) string { instanceOS := cloudprovider.DefaultOS @@ -112,7 +115,13 @@ func buildNodeFromTemplate(scaleSetName string, template compute.VirtualMachineS } node.Status.Capacity[apiv1.ResourcePods] = *resource.NewQuantity(110, resource.DecimalSI) node.Status.Capacity[apiv1.ResourceCPU] = *resource.NewQuantity(vmssType.VCPU, resource.DecimalSI) - node.Status.Capacity[gpu.ResourceNvidiaGPU] = *resource.NewQuantity(vmssType.GPU, resource.DecimalSI) + // isNPSeries returns if a SKU is an NP-series SKU + // SKU API reports GPUs for NP-series but it's actually FPGAs + if isNPSeries(*template.Sku.Name) { + node.Status.Capacity[xilinxFpgaResourceName] = *resource.NewQuantity(vmssType.GPU, resource.DecimalSI) + } else { + node.Status.Capacity[gpu.ResourceNvidiaGPU] = *resource.NewQuantity(vmssType.GPU, resource.DecimalSI) + } node.Status.Capacity[apiv1.ResourceMemory] = *resource.NewQuantity(vmssType.MemoryMb*1024*1024, resource.DecimalSI) resourcesFromTags := extractAllocatableResourcesFromScaleSet(template.Tags) @@ -255,3 +264,9 @@ func extractAllocatableResourcesFromScaleSet(tags map[string]*string) map[string return resources } + +// isNPSeries returns if a SKU is an NP-series SKU +// SKU API reports GPUs for NP-series but it's actually FPGAs +func isNPSeries(name string) bool { + return strings.HasPrefix(strings.ToLower(name), "standard_np") +}