diff --git a/cluster-autoscaler/processors/nodegroupset/azure_nodegroups.go b/cluster-autoscaler/processors/nodegroupset/azure_nodegroups.go index c5bfced6ec89..3b615a620675 100644 --- a/cluster-autoscaler/processors/nodegroupset/azure_nodegroups.go +++ b/cluster-autoscaler/processors/nodegroupset/azure_nodegroups.go @@ -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] @@ -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 } diff --git a/cluster-autoscaler/processors/nodegroupset/azure_nodegroups_test.go b/cluster-autoscaler/processors/nodegroupset/azure_nodegroups_test.go index 61e21602379a..8b73f36111a1 100644 --- a/cluster-autoscaler/processors/nodegroupset/azure_nodegroups_test.go +++ b/cluster-autoscaler/processors/nodegroupset/azure_nodegroups_test.go @@ -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) {