Skip to content

Commit

Permalink
CA: enable the DRA feature gate whenever the DRA flag is passed
Browse files Browse the repository at this point in the history
This is needed so that the scheduler code correctly includes and
executes the DRA plugin.

We could just use the feature gate instead of the DRA flag in CA
(the feature gates flag is already there, just not really used),
but I guess there could be use-cases for having DRA enabled in the
cluster but not in CA (e.g. DRA being tested in the cluster, CA only
operating on non-DRA nodes/pods).
  • Loading branch information
towca committed Dec 11, 2024
1 parent 4566ca6 commit fec30d3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot/store"
"k8s.io/autoscaler/cluster-autoscaler/simulator/framework"
"k8s.io/autoscaler/cluster-autoscaler/simulator/scheduling"
"k8s.io/kubernetes/pkg/features"
kubelet_config "k8s.io/kubernetes/pkg/kubelet/apis/config"

"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -691,6 +692,15 @@ func main() {
featureGate.AddFlag(pflag.CommandLine)
kube_flag.InitFlags()

// If the DRA flag is passed, we need to set the DRA feature gate as well. The selection of scheduler plugins for the default
// scheduling profile depends on feature gates, and the DRA plugin is only included if the DRA feature gate is enabled. The DRA
// plugin itself also checks the DRA feature gate and doesn't do anything if it's not enabled.
if *enableDynamicResourceAllocation && !featureGate.Enabled(features.DynamicResourceAllocation) {
if err := featureGate.SetFromMap(map[string]bool{string(features.DynamicResourceAllocation): true}); err != nil {
klog.Fatalf("couldn't enable the DRA feature gate: %v", err)
}
}

leaderElection := defaultLeaderElectionConfiguration()
leaderElection.LeaderElect = true
componentopts.BindLeaderElectionFlags(&leaderElection, pflag.CommandLine)
Expand Down

0 comments on commit fec30d3

Please sign in to comment.