Skip to content

Commit

Permalink
Also set new (non-beta/non-deprecated) labels in buildGenericLabels
Browse files Browse the repository at this point in the history
This fixes issues when an ASG has 0 nodes yet and node labels are built
using buildGenericLabels and the node-template labels.

Issues include (anti-)affinity and nodeSelectors for the given labels,
giving false-negative results for candidate nodes, which leads to ASGs
never scaling up.
  • Loading branch information
codablock committed May 3, 2021
1 parent 3c28030 commit bd14102
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cluster-autoscaler/cloudprovider/aws/aws_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,24 @@ func (m *AwsManager) buildNodeFromTemplate(asg *asg, template *asgTemplate) (*ap

func buildGenericLabels(template *asgTemplate, nodeName string) map[string]string {
result := make(map[string]string)

// FYI, we are setting beta and deprecated labels as well here, as we can't know which labels were used in
// nodeSelectors and (anti-)affinity rules

// TODO: extract it somehow
result[kubeletapis.LabelArch] = cloudprovider.DefaultArch
result[kubeletapis.LabelOS] = cloudprovider.DefaultOS
result[kubeletapis.LabelArch] = cloudprovider.DefaultArch // beta label
result[kubeletapis.LabelOS] = cloudprovider.DefaultOS // beta label
result[apiv1.LabelArchStable] = cloudprovider.DefaultArch
result[apiv1.LabelOSStable] = cloudprovider.DefaultOS

result[apiv1.LabelInstanceType] = template.InstanceType.InstanceType // beta label
result[apiv1.LabelInstanceTypeStable] = template.InstanceType.InstanceType

result[apiv1.LabelInstanceType] = template.InstanceType.InstanceType
result[apiv1.LabelZoneRegion] = template.Region // deprecated label
result[apiv1.LabelZoneFailureDomain] = template.Zone // deprecated label
result[apiv1.LabelTopologyRegion] = template.Region
result[apiv1.LabelTopologyZone] = template.Zone

result[apiv1.LabelZoneRegion] = template.Region
result[apiv1.LabelZoneFailureDomain] = template.Zone
result[apiv1.LabelHostname] = nodeName
return result
}
Expand Down

0 comments on commit bd14102

Please sign in to comment.