-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add featuregates for volcano capabilities #2989
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2023 The Volcano Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package features | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/util/runtime" | ||
utilfeature "k8s.io/apiserver/pkg/util/feature" | ||
"k8s.io/component-base/featuregate" | ||
) | ||
|
||
const ( | ||
// WorkLoadSupport can cache and operate **K8s native resource**, Deployment/Replicas/ReplicationController/StatefulSet resources currently. | ||
WorkLoadSupport featuregate.Feature = "WorkLoadSupport" | ||
|
||
// VolcanoJobSupport can identify and schedule volcano job. | ||
VolcanoJobSupport featuregate.Feature = "VolcanoJobSupport" | ||
|
||
// QueueCommandSync supports queue command sync. | ||
QueueCommandSync featuregate.Feature = "QueueCommandSync" | ||
|
||
// PriorityClass to provide the capacity of preemption at pod group level. | ||
PriorityClass featuregate.Feature = "PriorityClass" | ||
|
||
// CSIStorage tracking of available storage capacity that CSI drivers provide | ||
CSIStorage featuregate.Feature = "CSIStorage" | ||
|
||
// ResourceTopology supports resources like cpu/memory topology aware. | ||
ResourceTopology featuregate.Feature = "ResourceTopology" | ||
) | ||
|
||
func init() { | ||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultVolcanoFeatureGates)) | ||
} | ||
|
||
var defaultVolcanoFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change |
||
WorkLoadSupport: {Default: true, PreRelease: featuregate.Alpha}, | ||
VolcanoJobSupport: {Default: true, PreRelease: featuregate.Alpha}, | ||
QueueCommandSync: {Default: true, PreRelease: featuregate.Alpha}, | ||
PriorityClass: {Default: true, PreRelease: featuregate.Alpha}, | ||
// CSIStorage is explicitly set to false by default. | ||
CSIStorage: {Default: false, PreRelease: featuregate.Alpha}, | ||
ResourceTopology: {Default: true, PreRelease: featuregate.Alpha}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import ( | |
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
utilfeature "k8s.io/apiserver/pkg/util/feature" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change |
||
"k8s.io/client-go/informers" | ||
infov1 "k8s.io/client-go/informers/core/v1" | ||
schedv1 "k8s.io/client-go/informers/scheduling/v1" | ||
|
@@ -60,6 +61,7 @@ import ( | |
vcinformerv1 "volcano.sh/apis/pkg/client/informers/externalversions/scheduling/v1beta1" | ||
|
||
"volcano.sh/volcano/cmd/scheduler/app/options" | ||
"volcano.sh/volcano/pkg/features" | ||
schedulingapi "volcano.sh/volcano/pkg/scheduler/api" | ||
volumescheduling "volcano.sh/volcano/pkg/scheduler/capabilities/volumebinding" | ||
"volcano.sh/volcano/pkg/scheduler/metrics" | ||
|
@@ -501,9 +503,11 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu | |
// `SelectorSpread` and `PodTopologySpread` plugins uses the following four so far. | ||
informerFactory.Core().V1().Namespaces().Informer() | ||
informerFactory.Core().V1().Services().Informer() | ||
informerFactory.Core().V1().ReplicationControllers().Informer() | ||
informerFactory.Apps().V1().ReplicaSets().Informer() | ||
informerFactory.Apps().V1().StatefulSets().Informer() | ||
if utilfeature.DefaultFeatureGate.Enabled(features.WorkLoadSupport) { | ||
informerFactory.Core().V1().ReplicationControllers().Informer() | ||
informerFactory.Apps().V1().ReplicaSets().Informer() | ||
informerFactory.Apps().V1().StatefulSets().Informer() | ||
} | ||
|
||
// create informer for node information | ||
sc.nodeInformer = informerFactory.Core().V1().Nodes() | ||
|
@@ -561,11 +565,11 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu | |
DeleteFunc: sc.DeleteCSINode, | ||
}, | ||
) | ||
sc.csiDriverInformer = informerFactory.Storage().V1().CSIDrivers() | ||
sc.csiStorageCapacityInformer = informerFactory.Storage().V1beta1().CSIStorageCapacities() | ||
|
||
var capacityCheck *volumescheduling.CapacityCheck | ||
if options.ServerOpts.EnableCSIStorage { | ||
if options.ServerOpts.EnableCSIStorage && utilfeature.DefaultFeatureGate.Enabled(features.CSIStorage) { | ||
sc.csiDriverInformer = informerFactory.Storage().V1().CSIDrivers() | ||
sc.csiStorageCapacityInformer = informerFactory.Storage().V1beta1().CSIStorageCapacities() | ||
capacityCheck = &volumescheduling.CapacityCheck{ | ||
CSIDriverInformer: sc.csiDriverInformer, | ||
CSIStorageCapacityInformer: sc.csiStorageCapacityInformer, | ||
|
@@ -621,7 +625,7 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu | |
}, | ||
}) | ||
|
||
if options.ServerOpts.EnablePriorityClass { | ||
if options.ServerOpts.EnablePriorityClass && utilfeature.DefaultFeatureGate.Enabled(features.PriorityClass) { | ||
sc.pcInformer = informerFactory.Scheduling().V1().PriorityClasses() | ||
sc.pcInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: sc.AddPriorityClass, | ||
|
@@ -677,12 +681,14 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu | |
DeleteFunc: sc.DeleteQueueV1beta1, | ||
}) | ||
|
||
sc.cpuInformer = vcinformers.Nodeinfo().V1alpha1().Numatopologies() | ||
sc.cpuInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: sc.AddNumaInfoV1alpha1, | ||
UpdateFunc: sc.UpdateNumaInfoV1alpha1, | ||
DeleteFunc: sc.DeleteNumaInfoV1alpha1, | ||
}) | ||
if utilfeature.DefaultFeatureGate.Enabled(features.ResourceTopology) { | ||
sc.cpuInformer = vcinformers.Nodeinfo().V1alpha1().Numatopologies() | ||
sc.cpuInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: sc.AddNumaInfoV1alpha1, | ||
UpdateFunc: sc.UpdateNumaInfoV1alpha1, | ||
DeleteFunc: sc.DeleteNumaInfoV1alpha1, | ||
}) | ||
} | ||
return sc | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to be simpled as
return v.TargetObject != nil && v.TargetObject.APIVersion == batchv1alpha1.SchemeGroupVersion.String() && v.TargetObject.Kind == "Job"