Skip to content

Commit

Permalink
Merge pull request #2617 from losipiuk/lo/templates-fixes
Browse files Browse the repository at this point in the history
 Set stable OS and Arch labels based on GCE template
  • Loading branch information
k8s-ci-robot authored Dec 6, 2019
2 parents 6940f47 + 9492283 commit f5cf06f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func BuildGenericLabels(ref GceRef, machineType string, nodeName string) (map[st

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

result[apiv1.LabelInstanceType] = machineType
ix := strings.LastIndex(ref.Zone, "-")
Expand Down
19 changes: 12 additions & 7 deletions cluster-autoscaler/cloudprovider/gce/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,23 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) {
}

func TestBuildGenericLabels(t *testing.T) {
expectedLabels := map[string]string{
apiv1.LabelZoneRegion: "us-central1",
apiv1.LabelZoneFailureDomain: "us-central1-b",
apiv1.LabelHostname: "sillyname",
apiv1.LabelInstanceType: "n1-standard-8",
kubeletapis.LabelArch: cloudprovider.DefaultArch,
kubeletapis.LabelOS: cloudprovider.DefaultOS,
apiv1.LabelArchStable: cloudprovider.DefaultArch,
apiv1.LabelOSStable: cloudprovider.DefaultOS,
}
labels, err := BuildGenericLabels(GceRef{
Name: "kubernetes-minion-group",
Project: "mwielgus-proj",
Zone: "us-central1-b"},
"n1-standard-8", "sillyname")
assert.Nil(t, err)
assert.Equal(t, "us-central1", labels[apiv1.LabelZoneRegion])
assert.Equal(t, "us-central1-b", labels[apiv1.LabelZoneFailureDomain])
assert.Equal(t, "sillyname", labels[apiv1.LabelHostname])
assert.Equal(t, "n1-standard-8", labels[apiv1.LabelInstanceType])
assert.Equal(t, cloudprovider.DefaultArch, labels[kubeletapis.LabelArch])
assert.Equal(t, cloudprovider.DefaultOS, labels[kubeletapis.LabelOS])
assert.NoError(t, err)
assert.Equal(t, expectedLabels, labels)
}

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

0 comments on commit f5cf06f

Please sign in to comment.