sched: start dynamicInformerFactory along with regular informerFactory (#105016)
* sched: start dynamicInformerFactory along with regular informerFactory * fixup: start all informers and then wait for their syncs
This commit is contained in:
@@ -245,6 +245,7 @@ func TestPolicyCompatibility(t *testing.T) {
|
||||
sched, err := scheduler.New(
|
||||
client,
|
||||
informerFactory,
|
||||
nil,
|
||||
recorderFactory,
|
||||
make(chan struct{}),
|
||||
scheduler.WithProfiles([]config.KubeSchedulerProfile(nil)...),
|
||||
|
@@ -422,6 +422,7 @@ func TestCreateFromConfig(t *testing.T) {
|
||||
_, err := New(
|
||||
client,
|
||||
informerFactory,
|
||||
nil,
|
||||
recorderFactory,
|
||||
make(chan struct{}),
|
||||
WithProfiles([]schedulerapi.KubeSchedulerProfile(nil)...),
|
||||
|
@@ -31,7 +31,6 @@ import (
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/dynamic/dynamicinformer"
|
||||
"k8s.io/client-go/informers"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
@@ -216,6 +215,7 @@ var defaultSchedulerOptions = schedulerOptions{
|
||||
// New returns a Scheduler
|
||||
func New(client clientset.Interface,
|
||||
informerFactory informers.SharedInformerFactory,
|
||||
dynInformerFactory dynamicinformer.DynamicSharedInformerFactory,
|
||||
recorderFactory profile.RecorderFactory,
|
||||
stopCh <-chan struct{},
|
||||
opts ...Option) (*Scheduler, error) {
|
||||
@@ -307,20 +307,8 @@ func New(client clientset.Interface,
|
||||
sched.StopEverything = stopEverything
|
||||
sched.client = client
|
||||
|
||||
// Build dynamic client and dynamic informer factory
|
||||
var dynInformerFactory dynamicinformer.DynamicSharedInformerFactory
|
||||
// options.kubeConfig can be nil in tests.
|
||||
if options.kubeConfig != nil {
|
||||
dynClient := dynamic.NewForConfigOrDie(options.kubeConfig)
|
||||
dynInformerFactory = dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynClient, 0, v1.NamespaceAll, nil)
|
||||
}
|
||||
|
||||
addAllEventHandlers(sched, informerFactory, dynInformerFactory, unionedGVKs(clusterEventMap))
|
||||
|
||||
if dynInformerFactory != nil {
|
||||
dynInformerFactory.Start(stopEverything)
|
||||
}
|
||||
|
||||
return sched, nil
|
||||
}
|
||||
|
||||
|
@@ -245,6 +245,7 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
s, err := New(
|
||||
client,
|
||||
informerFactory,
|
||||
nil,
|
||||
profile.NewRecorderFactory(eventBroadcaster),
|
||||
stopCh,
|
||||
tc.opts...,
|
||||
@@ -553,6 +554,7 @@ func TestSchedulerMultipleProfilesScheduling(t *testing.T) {
|
||||
sched, err := New(
|
||||
client,
|
||||
informerFactory,
|
||||
nil,
|
||||
profile.NewRecorderFactory(broadcaster),
|
||||
ctx.Done(),
|
||||
WithProfiles(
|
||||
|
Reference in New Issue
Block a user