mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
feat(scheduler): expose SharedInformerFactory to the framework handle
This commit is contained in:
parent
5e0f48acf8
commit
ee4dec65b5
@ -167,17 +167,8 @@ func Run(cc schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}, regis
|
||||
|
||||
// Create the scheduler.
|
||||
sched, err := scheduler.New(cc.Client,
|
||||
cc.InformerFactory.Core().V1().Nodes(),
|
||||
cc.InformerFactory,
|
||||
cc.PodInformer,
|
||||
cc.InformerFactory.Core().V1().PersistentVolumes(),
|
||||
cc.InformerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
cc.InformerFactory.Core().V1().ReplicationControllers(),
|
||||
cc.InformerFactory.Apps().V1().ReplicaSets(),
|
||||
cc.InformerFactory.Apps().V1().StatefulSets(),
|
||||
cc.InformerFactory.Core().V1().Services(),
|
||||
cc.InformerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
cc.InformerFactory.Storage().V1().StorageClasses(),
|
||||
cc.InformerFactory.Storage().V1beta1().CSINodes(),
|
||||
cc.Recorder,
|
||||
cc.ComponentConfig.AlgorithmSource,
|
||||
stopCh,
|
||||
|
@ -30,11 +30,8 @@ go_library(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/apps/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/policy/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/storage/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/events:go_default_library",
|
||||
|
@ -1172,17 +1172,8 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
||||
|
||||
sched, err := scheduler.New(
|
||||
client,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
informerFactory.Core().V1().Pods(),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
nil,
|
||||
algorithmSrc,
|
||||
make(chan struct{}),
|
||||
|
@ -27,9 +27,8 @@ import (
|
||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/informers"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
storageinformersv1 "k8s.io/client-go/informers/storage/v1"
|
||||
storageinformersv1beta1 "k8s.io/client-go/informers/storage/v1beta1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
)
|
||||
@ -381,13 +380,8 @@ func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
|
||||
func AddAllEventHandlers(
|
||||
sched *Scheduler,
|
||||
schedulerName string,
|
||||
nodeInformer coreinformers.NodeInformer,
|
||||
informerFactory informers.SharedInformerFactory,
|
||||
podInformer coreinformers.PodInformer,
|
||||
pvInformer coreinformers.PersistentVolumeInformer,
|
||||
pvcInformer coreinformers.PersistentVolumeClaimInformer,
|
||||
serviceInformer coreinformers.ServiceInformer,
|
||||
storageClassInformer storageinformersv1.StorageClassInformer,
|
||||
csiNodeInformer storageinformersv1beta1.CSINodeInformer,
|
||||
) {
|
||||
// scheduled pod cache
|
||||
podInformer.Informer().AddEventHandler(
|
||||
@ -440,7 +434,7 @@ func AddAllEventHandlers(
|
||||
},
|
||||
)
|
||||
|
||||
nodeInformer.Informer().AddEventHandler(
|
||||
informerFactory.Core().V1().Nodes().Informer().AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: sched.addNodeToCache,
|
||||
UpdateFunc: sched.updateNodeInCache,
|
||||
@ -449,7 +443,7 @@ func AddAllEventHandlers(
|
||||
)
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.CSINodeInfo) {
|
||||
csiNodeInformer.Informer().AddEventHandler(
|
||||
informerFactory.Storage().V1beta1().CSINodes().Informer().AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: sched.onCSINodeAdd,
|
||||
UpdateFunc: sched.onCSINodeUpdate,
|
||||
@ -460,7 +454,7 @@ func AddAllEventHandlers(
|
||||
|
||||
// On add and delete of PVs, it will affect equivalence cache items
|
||||
// related to persistent volume
|
||||
pvInformer.Informer().AddEventHandler(
|
||||
informerFactory.Core().V1().PersistentVolumes().Informer().AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
// MaxPDVolumeCountPredicate: since it relies on the counts of PV.
|
||||
AddFunc: sched.onPvAdd,
|
||||
@ -469,7 +463,7 @@ func AddAllEventHandlers(
|
||||
)
|
||||
|
||||
// This is for MaxPDVolumeCountPredicate: add/delete PVC will affect counts of PV when it is bound.
|
||||
pvcInformer.Informer().AddEventHandler(
|
||||
informerFactory.Core().V1().PersistentVolumeClaims().Informer().AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: sched.onPvcAdd,
|
||||
UpdateFunc: sched.onPvcUpdate,
|
||||
@ -479,7 +473,7 @@ func AddAllEventHandlers(
|
||||
// This is for ServiceAffinity: affected by the selector of the service is updated.
|
||||
// Also, if new service is added, equivalence cache will also become invalid since
|
||||
// existing pods may be "captured" by this service and change this predicate result.
|
||||
serviceInformer.Informer().AddEventHandler(
|
||||
informerFactory.Core().V1().Services().Informer().AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: sched.onServiceAdd,
|
||||
UpdateFunc: sched.onServiceUpdate,
|
||||
@ -487,7 +481,7 @@ func AddAllEventHandlers(
|
||||
},
|
||||
)
|
||||
|
||||
storageClassInformer.Informer().AddEventHandler(
|
||||
informerFactory.Storage().V1().StorageClasses().Informer().AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: sched.onStorageClassAdd,
|
||||
},
|
||||
|
@ -32,6 +32,7 @@ go_library(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/apps/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/policy/v1beta1:go_default_library",
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/informers"
|
||||
appsinformers "k8s.io/client-go/informers/apps/v1"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
policyinformers "k8s.io/client-go/informers/policy/v1beta1"
|
||||
@ -131,6 +132,9 @@ type PodPreemptor interface {
|
||||
// construct a new scheduler.
|
||||
type Configurator struct {
|
||||
client clientset.Interface
|
||||
|
||||
informerFactory informers.SharedInformerFactory
|
||||
|
||||
// a means to list all PersistentVolumes
|
||||
pVLister corelisters.PersistentVolumeLister
|
||||
// a means to list all PersistentVolumeClaims
|
||||
@ -196,6 +200,7 @@ type Configurator struct {
|
||||
// ConfigFactoryArgs is a set arguments passed to NewConfigFactory.
|
||||
type ConfigFactoryArgs struct {
|
||||
Client clientset.Interface
|
||||
InformerFactory informers.SharedInformerFactory
|
||||
NodeInformer coreinformers.NodeInformer
|
||||
PodInformer coreinformers.PodInformer
|
||||
PvInformer coreinformers.PersistentVolumeInformer
|
||||
@ -243,6 +248,7 @@ func NewConfigFactory(args *ConfigFactoryArgs) *Configurator {
|
||||
|
||||
c := &Configurator{
|
||||
client: args.Client,
|
||||
informerFactory: args.InformerFactory,
|
||||
pVLister: args.PvInformer.Lister(),
|
||||
pVCLister: args.PvcInformer.Lister(),
|
||||
serviceLister: args.ServiceInformer.Lister(),
|
||||
@ -416,6 +422,7 @@ func (c *Configurator) CreateFromKeys(predicateKeys, priorityKeys sets.String, e
|
||||
&plugins,
|
||||
pluginConfig,
|
||||
framework.WithClientSet(c.client),
|
||||
framework.WithInformerFactory(c.informerFactory),
|
||||
)
|
||||
if err != nil {
|
||||
klog.Fatalf("error initializing the scheduling framework: %v", err)
|
||||
|
@ -482,6 +482,7 @@ func newConfigFactoryWithFrameworkRegistry(
|
||||
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
||||
return NewConfigFactory(&ConfigFactoryArgs{
|
||||
Client: client,
|
||||
InformerFactory: informerFactory,
|
||||
NodeInformer: informerFactory.Core().V1().Nodes(),
|
||||
PodInformer: informerFactory.Core().V1().Pods(),
|
||||
PvInformer: informerFactory.Core().V1().PersistentVolumes(),
|
||||
|
@ -20,6 +20,7 @@ go_library(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/klog"
|
||||
@ -58,7 +59,8 @@ type framework struct {
|
||||
unreservePlugins []UnreservePlugin
|
||||
permitPlugins []PermitPlugin
|
||||
|
||||
clientSet clientset.Interface
|
||||
clientSet clientset.Interface
|
||||
informerFactory informers.SharedInformerFactory
|
||||
}
|
||||
|
||||
// extensionPoint encapsulates desired and applied set of plugins at a specific extension
|
||||
@ -89,7 +91,8 @@ func (f *framework) getExtensionPoints(plugins *config.Plugins) []extensionPoint
|
||||
}
|
||||
|
||||
type frameworkOptions struct {
|
||||
clientSet clientset.Interface
|
||||
clientSet clientset.Interface
|
||||
informerFactory informers.SharedInformerFactory
|
||||
}
|
||||
|
||||
// Option for the framework.
|
||||
@ -102,6 +105,13 @@ func WithClientSet(clientSet clientset.Interface) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithInformerFactory sets informer factory for the scheduling framework.
|
||||
func WithInformerFactory(informerFactory informers.SharedInformerFactory) Option {
|
||||
return func(o *frameworkOptions) {
|
||||
o.informerFactory = informerFactory
|
||||
}
|
||||
}
|
||||
|
||||
var defaultFrameworkOptions = frameworkOptions{}
|
||||
|
||||
var _ = Framework(&framework{})
|
||||
@ -119,6 +129,7 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
|
||||
pluginNameToWeightMap: make(map[string]int),
|
||||
waitingPods: newWaitingPodsMap(),
|
||||
clientSet: options.clientSet,
|
||||
informerFactory: options.informerFactory,
|
||||
}
|
||||
if plugins == nil {
|
||||
return f, nil
|
||||
@ -578,6 +589,11 @@ func (f *framework) ClientSet() clientset.Interface {
|
||||
return f.clientSet
|
||||
}
|
||||
|
||||
// SharedInformerFactory returns a shared informer factory.
|
||||
func (f *framework) SharedInformerFactory() informers.SharedInformerFactory {
|
||||
return f.informerFactory
|
||||
}
|
||||
|
||||
func (f *framework) pluginsNeeded(plugins *config.Plugins) map[string]config.Plugin {
|
||||
pgMap := make(map[string]config.Plugin, 0)
|
||||
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
||||
)
|
||||
@ -452,4 +453,6 @@ type FrameworkHandle interface {
|
||||
|
||||
// ClientSet returns a kubernetes clientSet.
|
||||
ClientSet() clientset.Interface
|
||||
|
||||
SharedInformerFactory() informers.SharedInformerFactory
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ go_test(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/metrics/testutil:go_default_library",
|
||||
],
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/component-base/metrics/testutil"
|
||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||
@ -227,6 +228,10 @@ func (*fakeFramework) ClientSet() clientset.Interface {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*fakeFramework) SharedInformerFactory() informers.SharedInformerFactory {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestPriorityQueue_AddWithReversePriorityLessFunc(t *testing.T) {
|
||||
q := NewPriorityQueue(nil, &fakeFramework{})
|
||||
if err := q.Add(&medPriorityPod); err != nil {
|
||||
|
@ -28,11 +28,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
appsinformers "k8s.io/client-go/informers/apps/v1"
|
||||
"k8s.io/client-go/informers"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
policyinformers "k8s.io/client-go/informers/policy/v1beta1"
|
||||
storageinformersv1 "k8s.io/client-go/informers/storage/v1"
|
||||
storageinformersv1beta1 "k8s.io/client-go/informers/storage/v1beta1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/events"
|
||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||
@ -241,17 +238,8 @@ var defaultSchedulerOptions = schedulerOptions{
|
||||
|
||||
// New returns a Scheduler
|
||||
func New(client clientset.Interface,
|
||||
nodeInformer coreinformers.NodeInformer,
|
||||
informerFactory informers.SharedInformerFactory,
|
||||
podInformer coreinformers.PodInformer,
|
||||
pvInformer coreinformers.PersistentVolumeInformer,
|
||||
pvcInformer coreinformers.PersistentVolumeClaimInformer,
|
||||
replicationControllerInformer coreinformers.ReplicationControllerInformer,
|
||||
replicaSetInformer appsinformers.ReplicaSetInformer,
|
||||
statefulSetInformer appsinformers.StatefulSetInformer,
|
||||
serviceInformer coreinformers.ServiceInformer,
|
||||
pdbInformer policyinformers.PodDisruptionBudgetInformer,
|
||||
storageClassInformer storageinformersv1.StorageClassInformer,
|
||||
csiNodeInformer storageinformersv1beta1.CSINodeInformer,
|
||||
recorder events.EventRecorder,
|
||||
schedulerAlgorithmSource kubeschedulerconfig.SchedulerAlgorithmSource,
|
||||
stopCh <-chan struct{},
|
||||
@ -263,21 +251,27 @@ func New(client clientset.Interface,
|
||||
}
|
||||
|
||||
schedulerCache := internalcache.New(30*time.Second, stopCh)
|
||||
volumeBinder := volumebinder.NewVolumeBinder(client, nodeInformer, pvcInformer, pvInformer, storageClassInformer,
|
||||
time.Duration(options.bindTimeoutSeconds)*time.Second)
|
||||
volumeBinder := volumebinder.NewVolumeBinder(
|
||||
client,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
time.Duration(options.bindTimeoutSeconds)*time.Second,
|
||||
)
|
||||
|
||||
registry := options.frameworkDefaultRegistry
|
||||
if registry == nil {
|
||||
registry = frameworkplugins.NewDefaultRegistry(&frameworkplugins.RegistryArgs{
|
||||
SchedulerCache: schedulerCache,
|
||||
ServiceLister: serviceInformer.Lister(),
|
||||
ControllerLister: replicationControllerInformer.Lister(),
|
||||
ReplicaSetLister: replicaSetInformer.Lister(),
|
||||
StatefulSetLister: statefulSetInformer.Lister(),
|
||||
PDBLister: pdbInformer.Lister(),
|
||||
PVLister: pvInformer.Lister(),
|
||||
PVCLister: pvcInformer.Lister(),
|
||||
StorageClassLister: storageClassInformer.Lister(),
|
||||
ServiceLister: informerFactory.Core().V1().Services().Lister(),
|
||||
ControllerLister: informerFactory.Core().V1().ReplicationControllers().Lister(),
|
||||
ReplicaSetLister: informerFactory.Apps().V1().ReplicaSets().Lister(),
|
||||
StatefulSetLister: informerFactory.Apps().V1().StatefulSets().Lister(),
|
||||
PDBLister: informerFactory.Policy().V1beta1().PodDisruptionBudgets().Lister(),
|
||||
PVLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
||||
PVCLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
||||
VolumeBinder: volumeBinder,
|
||||
})
|
||||
}
|
||||
@ -286,17 +280,18 @@ func New(client clientset.Interface,
|
||||
// Set up the configurator which can create schedulers from configs.
|
||||
configurator := factory.NewConfigFactory(&factory.ConfigFactoryArgs{
|
||||
Client: client,
|
||||
NodeInformer: nodeInformer,
|
||||
InformerFactory: informerFactory,
|
||||
PodInformer: podInformer,
|
||||
PvInformer: pvInformer,
|
||||
PvcInformer: pvcInformer,
|
||||
ReplicationControllerInformer: replicationControllerInformer,
|
||||
ReplicaSetInformer: replicaSetInformer,
|
||||
StatefulSetInformer: statefulSetInformer,
|
||||
ServiceInformer: serviceInformer,
|
||||
PdbInformer: pdbInformer,
|
||||
StorageClassInformer: storageClassInformer,
|
||||
CSINodeInformer: csiNodeInformer,
|
||||
NodeInformer: informerFactory.Core().V1().Nodes(),
|
||||
PvInformer: informerFactory.Core().V1().PersistentVolumes(),
|
||||
PvcInformer: informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
ReplicationControllerInformer: informerFactory.Core().V1().ReplicationControllers(),
|
||||
ReplicaSetInformer: informerFactory.Apps().V1().ReplicaSets(),
|
||||
StatefulSetInformer: informerFactory.Apps().V1().StatefulSets(),
|
||||
ServiceInformer: informerFactory.Core().V1().Services(),
|
||||
PdbInformer: informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
StorageClassInformer: informerFactory.Storage().V1().StorageClasses(),
|
||||
CSINodeInformer: informerFactory.Storage().V1beta1().CSINodes(),
|
||||
VolumeBinder: volumeBinder,
|
||||
SchedulerCache: schedulerCache,
|
||||
HardPodAffinitySymmetricWeight: options.hardPodAffinitySymmetricWeight,
|
||||
@ -349,7 +344,7 @@ func New(client clientset.Interface,
|
||||
// Create the scheduler.
|
||||
sched := NewFromConfig(config)
|
||||
sched.podConditionUpdater = &podConditionUpdaterImpl{client}
|
||||
AddAllEventHandlers(sched, options.schedulerName, nodeInformer, podInformer, pvInformer, pvcInformer, serviceInformer, storageClassInformer, csiNodeInformer)
|
||||
AddAllEventHandlers(sched, options.schedulerName, informerFactory, podInformer)
|
||||
return sched, nil
|
||||
}
|
||||
|
||||
|
@ -183,17 +183,8 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
_, err := New(client,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
factory.NewPodInformer(client, 0),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
eventBroadcaster.NewRecorder(scheme.Scheme, "scheduler"),
|
||||
kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &testSource},
|
||||
stopCh,
|
||||
|
@ -106,17 +106,8 @@ func setupScheduler(
|
||||
|
||||
sched, err := scheduler.New(
|
||||
cs,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
informerFactory.Core().V1().Pods(),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
eventBroadcaster.NewRecorder(
|
||||
legacyscheme.Scheme,
|
||||
v1.DefaultSchedulerName,
|
||||
|
@ -250,17 +250,8 @@ priorities: []
|
||||
defaultBindTimeout := int64(30)
|
||||
|
||||
sched, err := scheduler.New(clientSet,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
factory.NewPodInformer(clientSet, 0),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.DefaultSchedulerName),
|
||||
kubeschedulerconfig.SchedulerAlgorithmSource{
|
||||
Policy: &kubeschedulerconfig.SchedulerPolicySource{
|
||||
@ -322,17 +313,8 @@ func TestSchedulerCreationFromNonExistentConfigMap(t *testing.T) {
|
||||
defaultBindTimeout := int64(30)
|
||||
|
||||
_, err := scheduler.New(clientSet,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
factory.NewPodInformer(clientSet, 0),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.DefaultSchedulerName),
|
||||
kubeschedulerconfig.SchedulerAlgorithmSource{
|
||||
Policy: &kubeschedulerconfig.SchedulerPolicySource{
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
@ -184,17 +184,8 @@ func initTestSchedulerWithOptions(
|
||||
opts = append([]scheduler.Option{scheduler.WithBindTimeoutSeconds(600)}, opts...)
|
||||
context.scheduler, err = scheduler.New(
|
||||
context.clientSet,
|
||||
context.informerFactory.Core().V1().Nodes(),
|
||||
context.informerFactory,
|
||||
podInformer,
|
||||
context.informerFactory.Core().V1().PersistentVolumes(),
|
||||
context.informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
context.informerFactory.Core().V1().ReplicationControllers(),
|
||||
context.informerFactory.Apps().V1().ReplicaSets(),
|
||||
context.informerFactory.Apps().V1().StatefulSets(),
|
||||
context.informerFactory.Core().V1().Services(),
|
||||
context.informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
context.informerFactory.Storage().V1().StorageClasses(),
|
||||
context.informerFactory.Storage().V1beta1().CSINodes(),
|
||||
recorder,
|
||||
algorithmSrc,
|
||||
context.stopCh,
|
||||
|
@ -76,13 +76,8 @@ func StartScheduler(clientSet clientset.Interface) (*scheduler.Scheduler, Shutdo
|
||||
}
|
||||
scheduler.AddAllEventHandlers(sched,
|
||||
v1.DefaultSchedulerName,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
informerFactory.Core().V1().Pods(),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
)
|
||||
|
||||
informerFactory.Start(stopCh)
|
||||
@ -107,17 +102,8 @@ func createScheduler(
|
||||
|
||||
return scheduler.New(
|
||||
clientSet,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
informerFactory.Core().V1().Pods(),
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
recorder,
|
||||
schedulerconfig.SchedulerAlgorithmSource{
|
||||
Provider: &defaultProviderName,
|
||||
|
@ -142,17 +142,8 @@ func createSchedulerWithPodInformer(
|
||||
|
||||
return scheduler.New(
|
||||
clientSet,
|
||||
informerFactory.Core().V1().Nodes(),
|
||||
informerFactory,
|
||||
podInformer,
|
||||
informerFactory.Core().V1().PersistentVolumes(),
|
||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
informerFactory.Core().V1().ReplicationControllers(),
|
||||
informerFactory.Apps().V1().ReplicaSets(),
|
||||
informerFactory.Apps().V1().StatefulSets(),
|
||||
informerFactory.Core().V1().Services(),
|
||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
informerFactory.Storage().V1().StorageClasses(),
|
||||
informerFactory.Storage().V1beta1().CSINodes(),
|
||||
recorder,
|
||||
schedulerconfig.SchedulerAlgorithmSource{
|
||||
Provider: &defaultProviderName,
|
||||
|
Loading…
Reference in New Issue
Block a user