From fec30d3b85976095683f97a27eb0a8f6928c6c12 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 cab701af0af..cdf8050e19a 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)