diff --git a/pkg/controller/cloud/node_controller.go b/pkg/controller/cloud/node_controller.go index 17fedb72b13..f69ce0b5a24 100644 --- a/pkg/controller/cloud/node_controller.go +++ b/pkg/controller/cloud/node_controller.go @@ -70,6 +70,14 @@ var labelReconcileInfo = []struct { secondaryKey: v1.LabelZoneRegionStable, ensureSecondaryExists: true, }, + { + // Reconcile the beta and the stable instance-type label using the beta label as + // the source of truth + // TODO: switch the primary key to GA labels in v1.21 + primaryKey: v1.LabelInstanceType, + secondaryKey: v1.LabelInstanceTypeStable, + ensureSecondaryExists: true, + }, } var UpdateNodeSpecBackoff = wait.Backoff{ @@ -375,6 +383,8 @@ func (cnc *CloudNodeController) initializeNode(ctx context.Context, node *v1.Nod } else if instanceType != "" { klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelInstanceType, instanceType) curNode.ObjectMeta.Labels[v1.LabelInstanceType] = instanceType + klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelInstanceTypeStable, instanceType) + curNode.ObjectMeta.Labels[v1.LabelInstanceTypeStable] = instanceType } if zones, ok := cnc.cloud.Zones(); ok { diff --git a/pkg/controller/cloud/node_controller_test.go b/pkg/controller/cloud/node_controller_test.go index 5e10eb9236a..37470060f78 100644 --- a/pkg/controller/cloud/node_controller_test.go +++ b/pkg/controller/cloud/node_controller_test.go @@ -689,12 +689,15 @@ func Test_reconcileNodeLabels(t *testing.T) { labels: map[string]string{ v1.LabelZoneFailureDomain: "foo", v1.LabelZoneRegion: "bar", + v1.LabelInstanceType: "the-best-type", }, expectedLabels: map[string]string{ v1.LabelZoneFailureDomain: "foo", v1.LabelZoneRegion: "bar", v1.LabelZoneFailureDomainStable: "foo", v1.LabelZoneRegionStable: "bar", + v1.LabelInstanceType: "the-best-type", + v1.LabelInstanceTypeStable: "the-best-type", }, expectedErr: nil, }, @@ -705,12 +708,16 @@ func Test_reconcileNodeLabels(t *testing.T) { v1.LabelZoneRegion: "bar", v1.LabelZoneFailureDomainStable: "foo", v1.LabelZoneRegionStable: "bar", + v1.LabelInstanceType: "the-best-type", + v1.LabelInstanceTypeStable: "the-best-type", }, expectedLabels: map[string]string{ v1.LabelZoneFailureDomain: "foo", v1.LabelZoneRegion: "bar", v1.LabelZoneFailureDomainStable: "foo", v1.LabelZoneRegionStable: "bar", + v1.LabelInstanceType: "the-best-type", + v1.LabelInstanceTypeStable: "the-best-type", }, expectedErr: nil, }, @@ -721,12 +728,16 @@ func Test_reconcileNodeLabels(t *testing.T) { v1.LabelZoneRegion: "bar", v1.LabelZoneFailureDomainStable: "wrongfoo", v1.LabelZoneRegionStable: "wrongbar", + v1.LabelInstanceType: "the-best-type", + v1.LabelInstanceTypeStable: "the-wrong-type", }, expectedLabels: map[string]string{ v1.LabelZoneFailureDomain: "foo", v1.LabelZoneRegion: "bar", v1.LabelZoneFailureDomainStable: "foo", v1.LabelZoneRegionStable: "bar", + v1.LabelInstanceType: "the-best-type", + v1.LabelInstanceTypeStable: "the-best-type", }, expectedErr: nil, },