Skip to content

Commit

Permalink
Rename IgnoreTaints to StartupTaints & deprecate --ignore-taints flag
Browse files Browse the repository at this point in the history
  • Loading branch information
atwamahmoud committed Sep 26, 2023
1 parent 6bf31ca commit f9d3185
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cluster-autoscaler/core/static_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions cluster-autoscaler/utils/taints/taints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand All @@ -80,7 +80,7 @@ func NewTaintConfig(opts config.AutoscalingOptions) TaintConfig {
}

return TaintConfig{
IgnoredTaints: ignoredTaints,
StartupTaints: startupTaints,
StatusTaints: statusTaints,
}
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
22 changes: 11 additions & 11 deletions cluster-autoscaler/utils/taints/taints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,27 +327,27 @@ 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,
},
"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{
Expand All @@ -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{
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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},
}

Expand Down

0 comments on commit f9d3185

Please sign in to comment.