diff --git a/cluster-autoscaler/config/autoscaling_options.go b/cluster-autoscaler/config/autoscaling_options.go index dc8e51fd213d..a4a42f4ae357 100644 --- a/cluster-autoscaler/config/autoscaling_options.go +++ b/cluster-autoscaler/config/autoscaling_options.go @@ -277,6 +277,6 @@ type AutoscalingOptions struct { // dynamicNodeDeleteDelayAfterTaintEnabled is used to enable/disable dynamic adjustment of NodeDeleteDelayAfterTaint // based on the latency between the CA and the api-server DynamicNodeDeleteDelayAfterTaintEnabled bool - //BypassedSchedulers are used to specify which schedulers to bypass their processing + // BypassedSchedulers are used to specify which schedulers to bypass their processing BypassedSchedulers map[string]bool } diff --git a/cluster-autoscaler/core/static_autoscaler_test.go b/cluster-autoscaler/core/static_autoscaler_test.go index 145741e0f012..55906cf94350 100644 --- a/cluster-autoscaler/core/static_autoscaler_test.go +++ b/cluster-autoscaler/core/static_autoscaler_test.go @@ -51,6 +51,7 @@ import ( "k8s.io/autoscaler/cluster-autoscaler/utils/errors" "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes" kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes" + "k8s.io/autoscaler/cluster-autoscaler/utils/scheduler" "k8s.io/autoscaler/cluster-autoscaler/utils/taints" . "k8s.io/autoscaler/cluster-autoscaler/utils/test" kube_record "k8s.io/client-go/tools/record" @@ -1122,10 +1123,10 @@ func TestStaticAutoscalerRunOnceWithSchedulerProcessingIgnored(t *testing.T) { MaxNodesTotal: 10, MaxCoresTotal: 10, MaxMemoryTotal: 100000, - BypassedSchedulers: map[string]bool{ - apiv1.DefaultSchedulerName: true, - bypassedScheduler: true, - }, + BypassedSchedulers: scheduler.GetBypassedSchedulersMap([]string{ + apiv1.DefaultSchedulerName, + bypassedScheduler, + }), } n1 := BuildTestNode("n1", 1000, 1000) diff --git a/cluster-autoscaler/utils/kubernetes/listers.go b/cluster-autoscaler/utils/kubernetes/listers.go index c599c38fe801..b9be94b6e665 100644 --- a/cluster-autoscaler/utils/kubernetes/listers.go +++ b/cluster-autoscaler/utils/kubernetes/listers.go @@ -186,7 +186,7 @@ func SchedulerUnprocessedPods(allPods []*apiv1.Pod, bypassedSchedulers map[strin var unprocessedPods []*apiv1.Pod for _, pod := range allPods { - if isIgnored, found := bypassedSchedulers[pod.Spec.SchedulerName]; !found || !isIgnored { + if canBypass := bypassedSchedulers[pod.Spec.SchedulerName]; !canBypass { continue } // Make sure it's not scheduled or deleted diff --git a/cluster-autoscaler/utils/scheduler/scheduler.go b/cluster-autoscaler/utils/scheduler/scheduler.go index 5383449e44b2..cd981aa72fbf 100644 --- a/cluster-autoscaler/utils/scheduler/scheduler.go +++ b/cluster-autoscaler/utils/scheduler/scheduler.go @@ -148,14 +148,14 @@ func ConfigFromPath(path string) (*scheduler_config.KubeSchedulerConfiguration, return cfgObj, nil } -// GetBypassedSchedulersMap returns a map of scheduler names that should be ignored as keys, and values are set to true -// Also sets "" (empty string) to true if default scheduler is ignored +// GetBypassedSchedulersMap returns a map of scheduler names that should be bypassed as keys, and values are set to true +// Also sets "" (empty string) to true if default scheduler is bypassed func GetBypassedSchedulersMap(bypassedSchedulers []string) map[string]bool { bypassedSchedulersMap := make(map[string]bool, len(bypassedSchedulers)) for _, scheduler := range bypassedSchedulers { bypassedSchedulersMap[scheduler] = true } - if isIgnored, found := bypassedSchedulersMap[apiv1.DefaultSchedulerName]; isIgnored && found { + if canBypass := bypassedSchedulersMap[apiv1.DefaultSchedulerName]; canBypass { bypassedSchedulersMap[""] = true } return bypassedSchedulersMap