@@ -123,7 +123,7 @@ func (c TargetConfigController) sync(ctx context.Context, syncCtx factory.SyncCo
123
123
func createTargetConfigController_v311_00_to_latest (ctx context.Context , syncCtx factory.SyncContext , c TargetConfigController , operatorSpec * operatorv1.StaticPodOperatorSpec ) (bool , error ) {
124
124
errors := []error {}
125
125
126
- _ , _ , err := manageKubeSchedulerConfigMap_v311_00_to_latest (ctx , c .kubeClient .CoreV1 (), syncCtx .Recorder (), c .configSchedulerLister )
126
+ _ , _ , err := manageKubeSchedulerConfigMap_v311_00_to_latest (ctx , c .featureGates , c . kubeClient .CoreV1 (), syncCtx .Recorder (), c .configSchedulerLister )
127
127
if err != nil {
128
128
errors = append (errors , fmt .Errorf ("%q: %v" , "configmap" , err ))
129
129
}
@@ -168,7 +168,7 @@ func createTargetConfigController_v311_00_to_latest(ctx context.Context, syncCtx
168
168
return false , nil
169
169
}
170
170
171
- func manageKubeSchedulerConfigMap_v311_00_to_latest (ctx context.Context , client corev1client.ConfigMapsGetter , recorder events.Recorder , configSchedulerLister configlistersv1.SchedulerLister ) (* corev1.ConfigMap , bool , error ) {
171
+ func manageKubeSchedulerConfigMap_v311_00_to_latest (ctx context.Context , featureGates featuregates. FeatureGate , client corev1client.ConfigMapsGetter , recorder events.Recorder , configSchedulerLister configlistersv1.SchedulerLister ) (* corev1.ConfigMap , bool , error ) {
172
172
configMap := resourceread .ReadConfigMapV1OrDie (bindata .MustAsset ("assets/kube-scheduler/cm.yaml" ))
173
173
174
174
var kubeSchedulerConfiguration []byte
@@ -199,19 +199,30 @@ func manageKubeSchedulerConfigMap_v311_00_to_latest(ctx context.Context, client
199
199
return nil , false , err
200
200
}
201
201
202
+ var enableDRAPlugin bool
202
203
switch config .Spec .ProfileCustomizations .DynamicResourceAllocation {
203
204
case v1 .DRAEnablementEnabled :
205
+ enableDRAPlugin = true
206
+ case "" , v1 .DRAEnablementDisabled :
207
+ // no-op
208
+ default :
209
+ return nil , false , fmt .Errorf ("dynamicResourceAllocation customization %q not recognized" , config .Spec .ProfileCustomizations .DynamicResourceAllocation )
210
+ }
211
+ // if the feature gate DynamicResourceAllocation is enabled, we will enable the plugin
212
+ if ! enableDRAPlugin {
213
+ if featureGates .Enabled ("DynamicResourceAllocation" ) {
214
+ enableDRAPlugin = true
215
+ klog .Infof ("feature gate DynamicResourceAllocation is set, enabling the scheduler plugin" )
216
+ }
217
+ }
218
+ if enableDRAPlugin {
204
219
if len (schedulerConfiguration .Profiles ) == 0 {
205
220
schedulerConfiguration .Profiles = []schedulerconfigv1.KubeSchedulerProfile {{}}
206
221
}
207
222
if schedulerConfiguration .Profiles [0 ].Plugins == nil {
208
223
schedulerConfiguration .Profiles [0 ].Plugins = & schedulerconfigv1.Plugins {}
209
224
}
210
225
schedulerConfiguration .Profiles [0 ].Plugins .MultiPoint .Enabled = append (schedulerConfiguration .Profiles [0 ].Plugins .MultiPoint .Enabled , schedulerconfigv1.Plugin {Name : "DynamicResources" })
211
- case "" , v1 .DRAEnablementDisabled :
212
- // no-op
213
- default :
214
- return nil , false , fmt .Errorf ("dynamicResourceAllocation customization %q not recognized" , config .Spec .ProfileCustomizations .DynamicResourceAllocation )
215
226
}
216
227
217
228
schedulerConfigurationBytes , err := yaml .Marshal (schedulerConfiguration )
0 commit comments