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 24537b1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cluster-autoscaler/cloudprovider/azure/azure_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ 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[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 +259,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 24537b1

Please sign in to comment.