Skip to content

Commit

Permalink
azure labels to skip in nodegroupset
Browse files Browse the repository at this point in the history
  • Loading branch information
gandhipr committed Mar 14, 2024
1 parent ffe9680 commit cb3c22f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cluster-autoscaler/processors/nodegroupset/azure_nodegroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ const AzureNodepoolLabel = "kubernetes.azure.com/agentpool"
// AzureDiskTopologyKey is the topology key of Azure Disk CSI driver
const AzureDiskTopologyKey = "topology.disk.csi.azure.com/zone"

// Those labels are added on the VMSS and shouldn't affect nodepool similarity
const aksEngineVersionLabel = "aksEngineVersion"
const creationSource = "creationSource"
const poolName = "poolName"
const resourceNameSuffix = "resourceNameSuffix"
const aksConsolidatedAdditionalProperties = "kubernetes.azure.com/consolidated-additional-properties"

// AKS node image version
const aksNodeImageVersion = "kubernetes.azure.com/node-image-version"

func nodesFromSameAzureNodePool(n1, n2 *schedulerframework.NodeInfo) bool {
n1AzureNodePool := n1.Node().Labels[AzureNodepoolLabel]
n2AzureNodePool := n2.Node().Labels[AzureNodepoolLabel]
Expand All @@ -53,6 +63,13 @@ func CreateAzureNodeInfoComparator(extraIgnoredLabels []string, ratioOpts config
azureIgnoredLabels[AzureNodepoolLegacyLabel] = true
azureIgnoredLabels[AzureNodepoolLabel] = true
azureIgnoredLabels[AzureDiskTopologyKey] = true
azureIgnoredLabels[aksEngineVersionLabel] = true
azureIgnoredLabels[creationSource] = true
azureIgnoredLabels[poolName] = true
azureIgnoredLabels[resourceNameSuffix] = true
azureIgnoredLabels[aksNodeImageVersion] = true
azureIgnoredLabels[aksConsolidatedAdditionalProperties] = true

for _, k := range extraIgnoredLabels {
azureIgnoredLabels[k] = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,27 @@ func TestIsAzureNodeInfoSimilar(t *testing.T) {
n1.ObjectMeta.Labels["agentpool"] = "foo"
n2.ObjectMeta.Labels["agentpool"] = "bar"
checkNodesSimilar(t, n1, n2, comparator, true)
// Different creationSource
n1.ObjectMeta.Labels["creationSource"] = "aks-aks-nodepool2-vmss"
n2.ObjectMeta.Labels["creationSource"] = "aks-aks-nodepool3-vmss"
checkNodesSimilar(t, n1, n2, comparator, true)
// Different node image version
n1.ObjectMeta.Labels["kubernetes.azure.com/node-image-version"] = "AKSUbuntu-1804gen2-2021.01.28"
n2.ObjectMeta.Labels["kubernetes.azure.com/node-image-version"] = "AKSUbuntu-1804gen2-2022.01.30"
checkNodesSimilar(t, n1, n2, comparator, true)
// Custom label
n1.ObjectMeta.Labels["example.com/ready"] = "true"
n2.ObjectMeta.Labels["example.com/ready"] = "false"
checkNodesSimilar(t, n1, n2, comparator, true)
// One node with aksConsolidatedAdditionalProperties label
n1.ObjectMeta.Labels[aksConsolidatedAdditionalProperties] = "foo"
checkNodesSimilar(t, n1, n2, comparator, true)
// Same aksConsolidatedAdditionalProperties
n2.ObjectMeta.Labels[aksConsolidatedAdditionalProperties] = "foo"
checkNodesSimilar(t, n1, n2, comparator, true)
// Different aksConsolidatedAdditionalProperties label
n2.ObjectMeta.Labels[aksConsolidatedAdditionalProperties] = "bar"
checkNodesSimilar(t, n1, n2, comparator, true)
}

func TestFindSimilarNodeGroupsAzureBasic(t *testing.T) {
Expand Down

0 comments on commit cb3c22f

Please sign in to comment.