Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick of #3722: update generic labels for GCE #3771

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ func BuildGenericLabels(ref GceRef, machineType string, nodeName string, os Oper
result[apiv1.LabelOSStable] = string(os)

result[apiv1.LabelInstanceType] = machineType
result[apiv1.LabelInstanceTypeStable] = machineType
ix := strings.LastIndex(ref.Zone, "-")
if ix == -1 {
return nil, fmt.Errorf("unexpected zone: %s", ref.Zone)
}
result[apiv1.LabelZoneRegion] = ref.Zone[:ix]
result[apiv1.LabelZoneRegionStable] = ref.Zone[:ix]
result[apiv1.LabelZoneFailureDomain] = ref.Zone
result[apiv1.LabelZoneFailureDomainStable] = ref.Zone
result[gceCSITopologyKeyZone] = ref.Zone
result[apiv1.LabelHostname] = nodeName
return result, nil
Expand Down
21 changes: 12 additions & 9 deletions cluster-autoscaler/cloudprovider/gce/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,18 @@ func TestBuildGenericLabels(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
expectedLabels := map[string]string{
apiv1.LabelZoneRegion: "us-central1",
apiv1.LabelZoneFailureDomain: "us-central1-b",
gceCSITopologyKeyZone: "us-central1-b",
apiv1.LabelHostname: "sillyname",
apiv1.LabelInstanceType: "n1-standard-8",
kubeletapis.LabelArch: cloudprovider.DefaultArch,
kubeletapis.LabelOS: tc.expectedOsLabel,
apiv1.LabelArchStable: cloudprovider.DefaultArch,
apiv1.LabelOSStable: tc.expectedOsLabel,
apiv1.LabelZoneRegion: "us-central1",
apiv1.LabelZoneRegionStable: "us-central1",
apiv1.LabelZoneFailureDomain: "us-central1-b",
apiv1.LabelZoneFailureDomainStable: "us-central1-b",
gceCSITopologyKeyZone: "us-central1-b",
apiv1.LabelHostname: "sillyname",
apiv1.LabelInstanceType: "n1-standard-8",
apiv1.LabelInstanceTypeStable: "n1-standard-8",
kubeletapis.LabelArch: cloudprovider.DefaultArch,
kubeletapis.LabelOS: tc.expectedOsLabel,
apiv1.LabelArchStable: cloudprovider.DefaultArch,
apiv1.LabelOSStable: tc.expectedOsLabel,
}
labels, err := BuildGenericLabels(GceRef{
Name: "kubernetes-minion-group",
Expand Down