diff --git a/cluster-autoscaler/core/static_autoscaler.go b/cluster-autoscaler/core/static_autoscaler.go index c4bca6969b9b..6da20fd814b7 100644 --- a/cluster-autoscaler/core/static_autoscaler.go +++ b/cluster-autoscaler/core/static_autoscaler.go @@ -959,7 +959,7 @@ func (a *StaticAutoscaler) obtainNodeLists(cp cloudprovider.CloudProvider) ([]*a // our normal handling for booting up nodes deal with this. // TODO: Remove this call when we handle dynamically provisioned resources. allNodes, readyNodes = a.processors.CustomResourcesProcessor.FilterOutNodesWithUnreadyResources(a.AutoscalingContext, allNodes, readyNodes) - allNodes, readyNodes = taints.FilterOutNodesWithIgnoredTaints(a.taintConfig.IgnoredTaints, allNodes, readyNodes) + allNodes, readyNodes = taints.FilterOutNodesWithIgnoredTaints(a.taintConfig.StartupTaints, allNodes, readyNodes) return allNodes, readyNodes, nil } diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 0eb192d2d40e..5d3adeababab 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -197,7 +197,7 @@ var ( regional = flag.Bool("regional", false, "Cluster is regional.") newPodScaleUpDelay = flag.Duration("new-pod-scale-up-delay", 0*time.Second, "Pods less than this old will not be considered for scale-up. Can be increased for individual pods through annotation 'cluster-autoscaler.kubernetes.io/pod-scale-up-delay'.") - ignoreTaintsFlag = multiStringFlag("ignore-taint", "Specifies a taint to ignore in node templates when considering to scale a node group") + ignoreTaintsFlag = multiStringFlag("ignore-taint", "Specifies a taint to ignore in node templates when considering to scale a node group (Deprecated, use startup-taints instead)") startupTaintFlag = multiStringFlag("startup-taint", "Specifies a taint to ignore in node templates when considering to scale a node group (Equivalent to ignore-taint)") statusTaintsFlag = multiStringFlag("status-taint", "Specifies a taint to ignore in node templates when considering to scale a node group but nodes will not be treated as unready") balancingIgnoreLabelsFlag = multiStringFlag("balancing-ignore-label", "Specifies a label to ignore in addition to the basic and cloud-provider set of labels when comparing if two node groups are similar") diff --git a/cluster-autoscaler/utils/taints/taints.go b/cluster-autoscaler/utils/taints/taints.go index 241599b54ecc..62628ede25b9 100644 --- a/cluster-autoscaler/utils/taints/taints.go +++ b/cluster-autoscaler/utils/taints/taints.go @@ -47,8 +47,8 @@ const ( // StartupTaintPrefix (Same as IgnoreTaintPrefix) any taint starting with it will be filtered out from autoscaler template node. StartupTaintPrefix = "startup-taint.cluster-autoscaler.kubernetes.io/" - // DefaultStatusTaintPrefix any taint starting with it will be filtered out from autoscaler template node but unlike IgnoreTaintPrefix & StartTaintPrefix it should not be trated as unready. - DefaultStatusTaintPrefix = "status-taint.cluster-autoscaler.kubernetes.io/" + // StatusTaintPrefix any taint starting with it will be filtered out from autoscaler template node but unlike IgnoreTaintPrefix & StartupTaintPrefix it should not be trated as unready. + StatusTaintPrefix = "status-taint.cluster-autoscaler.kubernetes.io/" gkeNodeTerminationHandlerTaint = "cloud.google.com/impending-node-termination" @@ -61,16 +61,16 @@ type TaintKeySet map[string]bool // TaintConfig is a config of taints that require special handling type TaintConfig struct { - IgnoredTaints TaintKeySet + StartupTaints TaintKeySet StatusTaints TaintKeySet } // NewTaintConfig returns the taint config extracted from options func NewTaintConfig(opts config.AutoscalingOptions) TaintConfig { - ignoredTaints := make(TaintKeySet) + startupTaints := make(TaintKeySet) for _, taintKey := range opts.IgnoredTaints { klog.V(4).Infof("Ignoring taint %s on all NodeGroups", taintKey) - ignoredTaints[taintKey] = true + startupTaints[taintKey] = true } statusTaints := make(TaintKeySet) @@ -80,7 +80,7 @@ func NewTaintConfig(opts config.AutoscalingOptions) TaintConfig { } return TaintConfig{ - IgnoredTaints: ignoredTaints, + StartupTaints: startupTaints, StatusTaints: statusTaints, } } @@ -348,7 +348,7 @@ func SanitizeTaints(taints []apiv1.Taint, taintConfig TaintConfig) []apiv1.Taint continue } - if _, exists := taintConfig.IgnoredTaints[taint.Key]; exists { + if _, exists := taintConfig.StartupTaints[taint.Key]; exists { klog.V(4).Infof("Removing ignored taint %s, when creating template from node", taint.Key) continue } @@ -362,7 +362,7 @@ func SanitizeTaints(taints []apiv1.Taint, taintConfig TaintConfig) []apiv1.Taint klog.V(4).Infof("Removing taint %s based on prefix, when creation template from node", taint.Key) continue } - if strings.HasPrefix(taint.Key, DefaultStatusTaintPrefix) { + if strings.HasPrefix(taint.Key, StatusTaintPrefix) { klog.V(4).Infof("Removing status taint %s, when creating template from node", taint.Key) continue } diff --git a/cluster-autoscaler/utils/taints/taints_test.go b/cluster-autoscaler/utils/taints/taints_test.go index 43a7dde869b4..b9949cbabe89 100644 --- a/cluster-autoscaler/utils/taints/taints_test.go +++ b/cluster-autoscaler/utils/taints/taints_test.go @@ -327,19 +327,19 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { for name, tc := range map[string]struct { readyNodes int allNodes int - ignoredTaints TaintKeySet + startupTaints TaintKeySet node *apiv1.Node }{ "empty ignored taints, no node": { readyNodes: 0, allNodes: 0, - ignoredTaints: map[string]bool{}, + startupTaints: map[string]bool{}, node: nil, }, "one ignored taint, no node": { readyNodes: 0, allNodes: 0, - ignoredTaints: map[string]bool{ + startupTaints: map[string]bool{ "my-taint": true, }, node: nil, @@ -347,7 +347,7 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { "one ignored taint, one ready untainted node": { readyNodes: 1, allNodes: 1, - ignoredTaints: map[string]bool{ + startupTaints: map[string]bool{ "my-taint": true, }, node: &apiv1.Node{ @@ -366,7 +366,7 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { "one ignored taint, one unready tainted node": { readyNodes: 0, allNodes: 1, - ignoredTaints: map[string]bool{ + startupTaints: map[string]bool{ "my-taint": true, }, node: &apiv1.Node{ @@ -391,7 +391,7 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { "no ignored taint, one node unready prefixed with ignore taint": { readyNodes: 0, allNodes: 1, - ignoredTaints: map[string]bool{}, + startupTaints: map[string]bool{}, node: &apiv1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "notReadyTainted", @@ -414,7 +414,7 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { "no ignored taint, one node unready prefixed with startup taint": { readyNodes: 0, allNodes: 1, - ignoredTaints: map[string]bool{}, + startupTaints: map[string]bool{}, node: &apiv1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "notReadyTainted", @@ -437,7 +437,7 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { "no ignored taint, two taints": { readyNodes: 1, allNodes: 1, - ignoredTaints: map[string]bool{}, + startupTaints: map[string]bool{}, node: &apiv1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "ReadyTainted", @@ -468,7 +468,7 @@ func TestFilterOutNodesWithIgnoredTaints(t *testing.T) { if tc.node != nil { nodes = append(nodes, tc.node) } - allNodes, readyNodes := FilterOutNodesWithIgnoredTaints(tc.ignoredTaints, nodes, nodes) + allNodes, readyNodes := FilterOutNodesWithIgnoredTaints(tc.startupTaints, nodes, nodes) assert.Equal(t, tc.allNodes, len(allNodes)) assert.Equal(t, tc.readyNodes, len(readyNodes)) @@ -509,7 +509,7 @@ func TestSanitizeTaints(t *testing.T) { Effect: apiv1.TaintEffectNoSchedule, }, { - Key: DefaultStatusTaintPrefix + "some-taint", + Key: StatusTaintPrefix + "some-taint", Value: "myValue", Effect: apiv1.TaintEffectNoSchedule, }, @@ -555,7 +555,7 @@ func TestSanitizeTaints(t *testing.T) { }, } taintConfig := TaintConfig{ - IgnoredTaints: map[string]bool{"ignore-me": true}, + StartupTaints: map[string]bool{"ignore-me": true}, StatusTaints: map[string]bool{"status-me": true}, }