From 4c0188a14dfaa1936e4b48f4c4fc1332273bb136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Tu=C5=BCnik?= Date: Wed, 11 Dec 2024 18:40:07 +0100 Subject: [PATCH] CA: enable the DRA feature gate whenever the DRA flag is passed 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). --- cluster-autoscaler/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index cab701af0af7..cdf8050e19a8 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -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" @@ -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)