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:
Wei Huang
2021-09-16 19:33:00 -07:00
committed by GitHub
parent 2f10e6587c
commit a689ad4cda
11 changed files with 51 additions and 25 deletions

View File

@@ -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)...),

View File

@@ -422,6 +422,7 @@ func TestCreateFromConfig(t *testing.T) {
_, err := New(
client,
informerFactory,
nil,
recorderFactory,
make(chan struct{}),
WithProfiles([]schedulerapi.KubeSchedulerProfile(nil)...),

View File

@@ -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
}

View File

@@ -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(