Skip to content

Commit

Permalink
scheduler: config feature gate check for dynamic resources plugin
Browse files Browse the repository at this point in the history
As discussed for other plugins, a plugin that only does some work when a
certain feature gate is enabled should only get included in the default
configuration when that feature gate is enabled.

The plugin still needs to check the feature gate itself because it might be
enabled explicitly in some configuration, with the feature gate off.

Ref:
- #113705
- #113275 (comment)
  • Loading branch information
pohly committed Nov 8, 2022
1 parent 368a1ea commit 2e18e38
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
11 changes: 0 additions & 11 deletions pkg/scheduler/apis/config/testing/defaults/defaults.go
Expand Up @@ -345,7 +345,6 @@ var PluginsV1 = &config.Plugins{
{Name: names.NodeResourcesBalancedAllocation, Weight: 1},
{Name: names.ImageLocality, Weight: 1},
{Name: names.DefaultBinder},
{Name: names.DynamicResources},
},
},
}
Expand All @@ -366,7 +365,6 @@ var ExpandedPluginsV1 = &config.Plugins{
{Name: names.VolumeBinding},
{Name: names.PodTopologySpread},
{Name: names.InterPodAffinity},
{Name: names.DynamicResources},
},
},
Filter: config.PluginSet{
Expand All @@ -386,13 +384,11 @@ var ExpandedPluginsV1 = &config.Plugins{
{Name: names.VolumeZone},
{Name: names.PodTopologySpread},
{Name: names.InterPodAffinity},
{Name: names.DynamicResources},
},
},
PostFilter: config.PluginSet{
Enabled: []config.Plugin{
{Name: names.DefaultPreemption},
{Name: names.DynamicResources},
},
},
PreScore: config.PluginSet{
Expand All @@ -401,7 +397,6 @@ var ExpandedPluginsV1 = &config.Plugins{
{Name: names.NodeAffinity},
{Name: names.PodTopologySpread},
{Name: names.InterPodAffinity},
{Name: names.DynamicResources},
},
},
Score: config.PluginSet{
Expand Down Expand Up @@ -434,7 +429,6 @@ var ExpandedPluginsV1 = &config.Plugins{
Reserve: config.PluginSet{
Enabled: []config.Plugin{
{Name: names.VolumeBinding},
{Name: names.DynamicResources},
},
},
PreBind: config.PluginSet{
Expand All @@ -447,11 +441,6 @@ var ExpandedPluginsV1 = &config.Plugins{
{Name: names.DefaultBinder},
},
},
PostBind: config.PluginSet{
Enabled: []config.Plugin{
{Name: names.DynamicResources},
},
},
}

// PluginConfigsV1 default plugin configurations.
Expand Down
4 changes: 3 additions & 1 deletion pkg/scheduler/apis/config/v1/default_plugins.go
Expand Up @@ -51,7 +51,6 @@ func getDefaultPlugins() *v1.Plugins {
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)},
{Name: names.ImageLocality, Weight: pointer.Int32(1)},
{Name: names.DefaultBinder},
{Name: names.DynamicResources},
},
},
}
Expand All @@ -64,6 +63,9 @@ func applyFeatureGates(config *v1.Plugins) {
if utilfeature.DefaultFeatureGate.Enabled(features.PodSchedulingReadiness) {
config.MultiPoint.Enabled = append(config.MultiPoint.Enabled, v1.Plugin{Name: names.SchedulingGates})
}
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicResourceAllocation) {
config.MultiPoint.Enabled = append(config.MultiPoint.Enabled, v1.Plugin{Name: names.DynamicResources})
}
}

// mergePlugins merges the custom set into the given default one, handling disabled sets.
Expand Down
35 changes: 33 additions & 2 deletions pkg/scheduler/apis/config/v1/default_plugins_test.go
Expand Up @@ -60,7 +60,6 @@ func TestApplyFeatureGates(t *testing.T) {
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)},
{Name: names.ImageLocality, Weight: pointer.Int32(1)},
{Name: names.DefaultBinder},
{Name: names.DynamicResources},
},
},
},
Expand Down Expand Up @@ -93,12 +92,44 @@ func TestApplyFeatureGates(t *testing.T) {
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)},
{Name: names.ImageLocality, Weight: pointer.Int32(1)},
{Name: names.DefaultBinder},
{Name: names.DynamicResources},
{Name: names.SchedulingGates},
},
},
},
},
{
name: "Feature gate DynamicResourceAllocation enabled",
features: map[featuregate.Feature]bool{
features.DynamicResourceAllocation: true,
},
wantConfig: &v1.Plugins{
MultiPoint: v1.PluginSet{
Enabled: []v1.Plugin{
{Name: names.PrioritySort},
{Name: names.NodeUnschedulable},
{Name: names.NodeName},
{Name: names.TaintToleration, Weight: pointer.Int32(3)},
{Name: names.NodeAffinity, Weight: pointer.Int32(2)},
{Name: names.NodePorts},
{Name: names.NodeResourcesFit, Weight: pointer.Int32(1)},
{Name: names.VolumeRestrictions},
{Name: names.EBSLimits},
{Name: names.GCEPDLimits},
{Name: names.NodeVolumeLimits},
{Name: names.AzureDiskLimits},
{Name: names.VolumeBinding},
{Name: names.VolumeZone},
{Name: names.PodTopologySpread, Weight: pointer.Int32(2)},
{Name: names.InterPodAffinity, Weight: pointer.Int32(2)},
{Name: names.DefaultPreemption},
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)},
{Name: names.ImageLocality, Weight: pointer.Int32(1)},
{Name: names.DefaultBinder},
{Name: names.DynamicResources},
},
},
},
},
}

for _, test := range tests {
Expand Down
1 change: 0 additions & 1 deletion pkg/scheduler/apis/config/v1/defaults_test.go
Expand Up @@ -348,7 +348,6 @@ func TestSchedulerDefaults(t *testing.T) {
{Name: names.NodeResourcesBalancedAllocation, Weight: pointer.Int32(1)},
{Name: names.ImageLocality, Weight: pointer.Int32(1)},
{Name: names.DefaultBinder},
{Name: names.DynamicResources},
},
},
Bind: configv1.PluginSet{
Expand Down

0 comments on commit 2e18e38

Please sign in to comment.