Skip to content

Commit

Permalink
properly set FPGA capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanad committed Jan 25, 2022
1 parent 21a758c commit 3f01552
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cluster-autoscaler/cloudprovider/azure/azure_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}

0 comments on commit 3f01552

Please sign in to comment.