Skip to content

Commit

Permalink
Merge pull request #5276 from pacoxu/master
Browse files Browse the repository at this point in the history
Stop applying the beta.kubernetes.io/os and arch
  • Loading branch information
k8s-ci-robot authored Dec 16, 2022
2 parents bcd6447 + 8dec202 commit af23e61
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,6 @@ func (mgr *cherryManagerRest) deleteNodes(nodegroup string, nodes []NodeRef, upd
func BuildGenericLabels(nodegroup string, plan *Plan) map[string]string {
result := make(map[string]string)

//result[kubeletapis.LabelArch] = "amd64"
//result[kubeletapis.LabelOS] = "linux"
result[apiv1.LabelInstanceType] = plan.Name
//result[apiv1.LabelZoneRegion] = ""
//result[apiv1.LabelZoneFailureDomain] = "0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
kubeletapis "k8s.io/kubelet/pkg/apis"
schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"

"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
Expand Down Expand Up @@ -370,10 +369,8 @@ func buildGenericLabels(nodeName string) map[string]string {
// TODO revisit this function and add an explanation about what these
// labels are used for, or remove them if not necessary
m := make(map[string]string)
m[kubeletapis.LabelArch] = cloudprovider.DefaultArch
m[corev1.LabelArchStable] = cloudprovider.DefaultArch

m[kubeletapis.LabelOS] = cloudprovider.DefaultOS
m[corev1.LabelOSStable] = cloudprovider.DefaultOS

m[corev1.LabelHostname] = nodeName
Expand All @@ -387,10 +384,8 @@ func extractNodeLabels(node *corev1.Node) map[string]string {
return m
}

setLabelIfNotEmpty(m, node.Labels, kubeletapis.LabelArch)
setLabelIfNotEmpty(m, node.Labels, corev1.LabelArchStable)

setLabelIfNotEmpty(m, node.Labels, kubeletapis.LabelOS)
setLabelIfNotEmpty(m, node.Labels, corev1.LabelOSStable)

setLabelIfNotEmpty(m, node.Labels, corev1.LabelInstanceType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,10 +1309,8 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) {
config: testCaseConfig{
expectedErr: nil,
nodeLabels: map[string]string{
"kubernetes.io/os": "linux",
"beta.kubernetes.io/os": "linux",
"kubernetes.io/arch": "amd64",
"beta.kubernetes.io/arch": "amd64",
"kubernetes.io/os": "linux",
"kubernetes.io/arch": "amd64",
},
expectedCapacity: map[corev1.ResourceName]int64{
corev1.ResourceCPU: 2,
Expand All @@ -1321,11 +1319,9 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) {
gpuapis.ResourceNvidiaGPU: 1,
},
expectedNodeLabels: map[string]string{
"kubernetes.io/os": "linux",
"beta.kubernetes.io/os": "linux",
"kubernetes.io/arch": "amd64",
"beta.kubernetes.io/arch": "amd64",
"kubernetes.io/hostname": "random value",
"kubernetes.io/os": "linux",
"kubernetes.io/arch": "amd64",
"kubernetes.io/hostname": "random value",
},
},
},
Expand All @@ -1340,9 +1336,7 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) {
expectedErr: nil,
nodeLabels: map[string]string{
"kubernetes.io/os": "windows",
"beta.kubernetes.io/os": "windows",
"kubernetes.io/arch": "arm64",
"beta.kubernetes.io/arch": "arm64",
"node.kubernetes.io/instance-type": "instance1",
},
expectedCapacity: map[corev1.ResourceName]int64{
Expand All @@ -1353,9 +1347,7 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) {
expectedNodeLabels: map[string]string{
"kubernetes.io/hostname": "random value",
"kubernetes.io/os": "windows",
"beta.kubernetes.io/os": "windows",
"kubernetes.io/arch": "arm64",
"beta.kubernetes.io/arch": "arm64",
"node.kubernetes.io/instance-type": "instance1",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ package oci

import (
"fmt"
"gopkg.in/gcfg.v1"
"os"
"strconv"
"strings"
"time"

"gopkg.in/gcfg.v1"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/klog/v2"
kubeletapis "k8s.io/kubelet/pkg/apis"

"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"

Expand Down Expand Up @@ -526,10 +526,8 @@ func getInstancePoolAvailabilityDomain(ip *core.InstancePool) (string, error) {

func buildGenericLabelsForInstancePool(instancePool *core.InstancePool, nodeName, shape, availabilityDomain string) map[string]string {
result := make(map[string]string)
result[kubeletapis.LabelArch] = cloudprovider.DefaultArch
result[apiv1.LabelArchStable] = cloudprovider.DefaultArch

result[kubeletapis.LabelOS] = cloudprovider.DefaultOS
result[apiv1.LabelOSStable] = cloudprovider.DefaultOS

parts := strings.Split(*instancePool.Id, ".")
Expand Down
3 changes: 0 additions & 3 deletions cluster-autoscaler/cloudprovider/oci/oci_shape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
apiv1 "k8s.io/api/core/v1"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
kubeletapis "k8s.io/kubelet/pkg/apis"
"reflect"
"strings"
"testing"
Expand Down Expand Up @@ -182,9 +181,7 @@ func TestBuildGenericLabels(t *testing.T) {
availabilityDomain := "US-ASHBURN-1"

expected := map[string]string{
kubeletapis.LabelArch: cloudprovider.DefaultArch,
apiv1.LabelArchStable: cloudprovider.DefaultArch,
kubeletapis.LabelOS: cloudprovider.DefaultOS,
apiv1.LabelOSStable: cloudprovider.DefaultOS,
apiv1.LabelZoneRegion: "phx",
apiv1.LabelZoneRegionStable: "phx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,6 @@ func (mgr *packetManagerRest) deleteNodes(nodegroup string, nodes []NodeRef, upd
func BuildGenericLabels(nodegroup string, instanceType string) map[string]string {
result := make(map[string]string)

//result[kubeletapis.LabelArch] = "amd64"
//result[kubeletapis.LabelOS] = "linux"
result[apiv1.LabelInstanceType] = instanceType
//result[apiv1.LabelZoneRegion] = ""
//result[apiv1.LabelZoneFailureDomain] = "0"
Expand Down
4 changes: 2 additions & 2 deletions cluster-autoscaler/proposals/min_at_zero_gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ The basic set of labels in GKE is relatively simple.

```
labels:
beta.kubernetes.io/arch: amd64
kubernetes.io/arch: amd64
beta.kubernetes.io/instance-type: n1-standard-1
beta.kubernetes.io/os: linux
kubernetes.io/os: linux
cloud.google.com/gke-nodepool: default-pool
failure-domain.beta.kubernetes.io/region: us-central1
failure-domain.beta.kubernetes.io/zone: us-central1-a
Expand Down
7 changes: 0 additions & 7 deletions cluster-autoscaler/utils/labels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
kubeletapis "k8s.io/kubelet/pkg/apis"
)

var (
Expand Down Expand Up @@ -119,12 +118,6 @@ func calculateNodeSelectorStats(pods []*apiv1.Pod) []nodeSelectorStats {

// UpdateDeprecatedLabels updates beta and deprecated labels from stable labels
func UpdateDeprecatedLabels(labels map[string]string) {
if v, ok := labels[apiv1.LabelArchStable]; ok {
labels[kubeletapis.LabelArch] = v
}
if v, ok := labels[apiv1.LabelOSStable]; ok {
labels[kubeletapis.LabelOS] = v
}
if v, ok := labels[apiv1.LabelInstanceTypeStable]; ok {
labels[apiv1.LabelInstanceType] = v
}
Expand Down

0 comments on commit af23e61

Please sign in to comment.