@@ -211,7 +211,7 @@ func buildNodeTemplateFromVMPool(vmsPool armcontainerservice.AgentPool, location
211211 }, nil
212212}
213213
214- func buildNodeFromTemplate (nodeGroupName string , template NodeTemplate , manager * AzureManager , enableDynamicInstanceList bool ) (* apiv1.Node , error ) {
214+ func buildNodeFromTemplate (nodeGroupName string , template NodeTemplate , manager * AzureManager , enableDynamicInstanceList bool , enableLabelPrediction bool ) (* apiv1.Node , error ) {
215215 node := apiv1.Node {}
216216 nodeName := fmt .Sprintf ("%s-asg-%d" , nodeGroupName , rand .Int63 ())
217217
@@ -272,7 +272,7 @@ func buildNodeFromTemplate(nodeGroupName string, template NodeTemplate, manager
272272 node .Status .Allocatable = node .Status .Capacity
273273
274274 if template .VMSSNodeTemplate != nil {
275- node = processVMSSTemplate (template , nodeName , node )
275+ node = processVMSSTemplate (template , nodeName , node , enableLabelPrediction )
276276 } else if template .VMPoolNodeTemplate != nil {
277277 node = processVMPoolTemplate (template , nodeName , node )
278278 } else {
@@ -298,7 +298,7 @@ func processVMPoolTemplate(template NodeTemplate, nodeName string, node apiv1.No
298298 return node
299299}
300300
301- func processVMSSTemplate (template NodeTemplate , nodeName string , node apiv1.Node ) apiv1.Node {
301+ func processVMSSTemplate (template NodeTemplate , nodeName string , node apiv1.Node , enableLabelPrediction bool ) apiv1.Node {
302302 // NodeLabels
303303 if template .VMSSNodeTemplate .Tags != nil {
304304 for k , v := range template .VMSSNodeTemplate .Tags {
@@ -324,45 +324,50 @@ func processVMSSTemplate(template NodeTemplate, nodeName string, node apiv1.Node
324324 labels = extractLabelsFromTags (template .VMSSNodeTemplate .Tags )
325325 }
326326
327- // Add the agentpool label, its value should come from the VMSS poolName tag
328- // NOTE: The plan is for agentpool label to be deprecated in favor of the aks-prefixed one
329- // We will have to live with both labels for a while
330- if node .Labels [legacyPoolNameTag ] != "" {
331- labels [legacyAgentPoolNodeLabelKey ] = node .Labels [legacyPoolNameTag ]
332- labels [agentPoolNodeLabelKey ] = node .Labels [legacyPoolNameTag ]
333- }
334- if node .Labels [poolNameTag ] != "" {
335- labels [legacyAgentPoolNodeLabelKey ] = node .Labels [poolNameTag ]
336- labels [agentPoolNodeLabelKey ] = node .Labels [poolNameTag ]
337- }
338-
339- // Add the storage profile and storage tier labels for vmss node
340- if template .VMSSNodeTemplate .OSDisk != nil {
341- // ephemeral
342- if template .VMSSNodeTemplate .OSDisk .DiffDiskSettings != nil && template .VMSSNodeTemplate .OSDisk .DiffDiskSettings .Option == compute .Local {
343- labels [legacyStorageProfileNodeLabelKey ] = "ephemeral"
344- labels [storageProfileNodeLabelKey ] = "ephemeral"
345- } else {
346- labels [legacyStorageProfileNodeLabelKey ] = "managed"
347- labels [storageProfileNodeLabelKey ] = "managed"
327+ // This is the best-effort to match AKS system labels,
328+ // this prediction needs to be constantly worked on and maintained to keep up with the changes in AKS
329+ if enableLabelPrediction {
330+ // Add the agentpool label, its value should come from the VMSS poolName tag
331+ // NOTE: The plan is for agentpool label to be deprecated in favor of the aks-prefixed one
332+ // We will have to live with both labels for a while
333+ if node .Labels [legacyPoolNameTag ] != "" {
334+ labels [legacyAgentPoolNodeLabelKey ] = node .Labels [legacyPoolNameTag ]
335+ labels [agentPoolNodeLabelKey ] = node .Labels [legacyPoolNameTag ]
336+ }
337+ if node .Labels [poolNameTag ] != "" {
338+ labels [legacyAgentPoolNodeLabelKey ] = node .Labels [poolNameTag ]
339+ labels [agentPoolNodeLabelKey ] = node .Labels [poolNameTag ]
348340 }
349- if template .VMSSNodeTemplate .OSDisk .ManagedDisk != nil {
350- labels [legacyStorageTierNodeLabelKey ] = string (template .VMSSNodeTemplate .OSDisk .ManagedDisk .StorageAccountType )
351- labels [storageTierNodeLabelKey ] = string (template .VMSSNodeTemplate .OSDisk .ManagedDisk .StorageAccountType )
341+
342+ // Add the storage profile and storage tier labels for vmss node
343+ if template .VMSSNodeTemplate .OSDisk != nil {
344+ // ephemeral
345+ if template .VMSSNodeTemplate .OSDisk .DiffDiskSettings != nil && template .VMSSNodeTemplate .OSDisk .DiffDiskSettings .Option == compute .Local {
346+ labels [legacyStorageProfileNodeLabelKey ] = "ephemeral"
347+ labels [storageProfileNodeLabelKey ] = "ephemeral"
348+ } else {
349+ labels [legacyStorageProfileNodeLabelKey ] = "managed"
350+ labels [storageProfileNodeLabelKey ] = "managed"
351+ }
352+ if template .VMSSNodeTemplate .OSDisk .ManagedDisk != nil {
353+ labels [legacyStorageTierNodeLabelKey ] = string (template .VMSSNodeTemplate .OSDisk .ManagedDisk .StorageAccountType )
354+ labels [storageTierNodeLabelKey ] = string (template .VMSSNodeTemplate .OSDisk .ManagedDisk .StorageAccountType )
355+ }
352356 }
353- // Add ephemeral-storage value
354- if template .VMSSNodeTemplate .OSDisk .DiskSizeGB != nil {
355- node .Status .Capacity [apiv1 .ResourceEphemeralStorage ] = * resource .NewQuantity (int64 (int (* template .VMSSNodeTemplate .OSDisk .DiskSizeGB )* 1024 * 1024 * 1024 ), resource .DecimalSI )
356- klog .V (4 ).Infof ("OS Disk Size from template is: %d" , * template .VMSSNodeTemplate .OSDisk .DiskSizeGB )
357- klog .V (4 ).Infof ("Setting ephemeral storage to: %v" , node .Status .Capacity [apiv1 .ResourceEphemeralStorage ])
357+
358+ // If we are on GPU-enabled SKUs, append the accelerator
359+ // label so that CA makes better decision when scaling from zero for GPU pools
360+ if isNvidiaEnabledSKU (template .SkuName ) {
361+ labels [GPULabel ] = "nvidia"
362+ labels [legacyGPULabel ] = "nvidia"
358363 }
359364 }
360365
361- // If we are on GPU-enabled SKUs, append the accelerator
362- // label so that CA makes better decision when scaling from zero for GPU pools
363- if isNvidiaEnabledSKU ( template .SkuName ) {
364- labels [ GPULabel ] = "nvidia"
365- labels [ legacyGPULabel ] = "nvidia"
366+ // Add ephemeral-storage value
367+ if template . VMSSNodeTemplate . OSDisk != nil && template . VMSSNodeTemplate . OSDisk . DiskSizeGB != nil {
368+ node . Status . Capacity [ apiv1 . ResourceEphemeralStorage ] = * resource . NewQuantity ( int64 ( int ( * template .VMSSNodeTemplate . OSDisk . DiskSizeGB ) * 1024 * 1024 * 1024 ), resource . DecimalSI )
369+ klog . V ( 4 ). Infof ( "OS Disk Size from template is: %d" , * template . VMSSNodeTemplate . OSDisk . DiskSizeGB )
370+ klog . V ( 4 ). Infof ( "Setting ephemeral storage to: %v" , node . Status . Capacity [ apiv1 . ResourceEphemeralStorage ])
366371 }
367372
368373 // Extract allocatables from tags
0 commit comments