@@ -18,29 +18,27 @@ package util
1818
1919import (
2020 "fmt"
21- "strings"
2221
2322 corev1 "k8s.io/api/core/v1"
2423 clientset "k8s.io/client-go/kubernetes"
2524 "k8s.io/klog/v2"
2625 "k8s.io/perf-tests/clusterloader2/pkg/framework/client"
2726)
2827
29- const keyMasterNodeLabel = "node-role.kubernetes.io/master"
30- const keyControlPlaneNodeLabel = "node-role.kubernetes.io/control-plane"
28+ const keyControlPlaneNodeLabelTaint = "node-role.kubernetes.io/control-plane"
3129
3230// Based on the following docs:
3331// https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/#taint-based-evictions
3432// https://kubernetes.io/docs/reference/labels-annotations-taints/
3533var builtInTaintsKeys = []string {
3634 "node.kubernetes.io/not-ready" ,
3735 "node.kubernetes.io/unreachable" ,
38- "node.kubernetes.io/pid-pressure" ,
39- "node.kubernetes.io/out-of-disk" ,
36+ "node.kubernetes.io/unschedulable" ,
4037 "node.kubernetes.io/memory-pressure" ,
4138 "node.kubernetes.io/disk-pressure" ,
4239 "node.kubernetes.io/network-unavailable" ,
43- "node.kubernetes.io/unschedulable" ,
40+ "node.kubernetes.io/pid-pressure" ,
41+ "node.kubernetes.io/out-of-service" ,
4442 "node.cloudprovider.kubernetes.io/uninitialized" ,
4543 "node.cloudprovider.kubernetes.io/shutdown" ,
4644}
@@ -153,7 +151,7 @@ func GetMasterName(c clientset.Interface) (string, error) {
153151 return "" , err
154152 }
155153 for i := range nodeList {
156- if LegacyIsMasterNode ( & nodeList [ i ]) || IsControlPlaneNode (& nodeList [i ]) {
154+ if IsControlPlaneNode (& nodeList [i ]) {
157155 return nodeList [i ].Name , nil
158156 }
159157 }
@@ -168,7 +166,7 @@ func GetMasterIPs(c clientset.Interface, addressType corev1.NodeAddressType) ([]
168166 }
169167 var ips []string
170168 for i := range nodeList {
171- if LegacyIsMasterNode ( & nodeList [ i ]) || IsControlPlaneNode (& nodeList [i ]) {
169+ if IsControlPlaneNode (& nodeList [i ]) {
172170 for _ , address := range nodeList [i ].Status .Addresses {
173171 if address .Type == addressType && address .Address != "" {
174172 ips = append (ips , address .Address )
@@ -183,36 +181,15 @@ func GetMasterIPs(c clientset.Interface, addressType corev1.NodeAddressType) ([]
183181 return ips , nil
184182}
185183
186- // LegacyIsMasterNode returns true if given node is a registered master according
187- // to the logic historically used for this function. This code path is deprecated
188- // and the node disruption exclusion label should be used in the future.
189- // This code will not be allowed to update to use the node-role label, since
190- // node-roles may not be used for feature enablement.
191- // DEPRECATED: this will be removed in Kubernetes 1.19
192- func LegacyIsMasterNode (node * corev1.Node ) bool {
184+ func IsControlPlaneNode (node * corev1.Node ) bool {
193185 for key := range node .GetLabels () {
194- if key == keyMasterNodeLabel {
186+ if key == keyControlPlaneNodeLabelTaint {
195187 return true
196188 }
197189 }
198-
199- // We are trying to capture "master(-...)?$" regexp.
200- // However, using regexp.MatchString() results even in more than 35%
201- // of all space allocations in ControllerManager spent in this function.
202- // That's why we are trying to be a bit smarter.
203- nodeName := node .GetName ()
204- if strings .HasSuffix (nodeName , "master" ) {
205- return true
206- }
207- if len (nodeName ) >= 10 {
208- return strings .HasSuffix (nodeName [:len (nodeName )- 3 ], "master-" )
209- }
210- return false
211- }
212-
213- func IsControlPlaneNode (node * corev1.Node ) bool {
214- for key := range node .GetLabels () {
215- if key == keyControlPlaneNodeLabel {
190+ // https://kubernetes.io/docs/reference/labels-annotations-taints/#node-role-kubernetes-io-control-plane-taint
191+ for _ , taint := range node .Spec .Taints {
192+ if taint .Key == keyControlPlaneNodeLabelTaint {
216193 return true
217194 }
218195 }
0 commit comments