Merge pull request #100644 from Huang-Wei/sched-fwk-config

Surface kube config in scheduler framework handle
This commit is contained in:
Kubernetes Prow Robot
2021-04-12 19:12:49 -07:00
committed by GitHub
11 changed files with 55 additions and 14 deletions

View File

@@ -92,7 +92,7 @@ type BindPlugin struct {
numBindCalled int
PluginName string
bindStatus *framework.Status
client *clientset.Clientset
client clientset.Interface
pluginInvokeEventChan chan pluginInvokeEvent
}

View File

@@ -99,7 +99,7 @@ func mustSetupScheduler(config *config.KubeSchedulerConfiguration) (util.Shutdow
// Not all config options will be effective but only those mostly related with scheduler performance will
// be applied to start a scheduler, most of them are defined in `scheduler.schedulerOptions`.
_, podInformer, schedulerShutdown := util.StartScheduler(client, config)
_, podInformer, schedulerShutdown := util.StartScheduler(client, cfg, config)
fakePVControllerShutdown := util.StartFakePVController(client)
shutdownFunc := func() {

View File

@@ -75,7 +75,7 @@ func StartApiserver() (string, ShutdownFunc) {
// StartScheduler configures and starts a scheduler given a handle to the clientSet interface
// and event broadcaster. It returns the running scheduler, podInformer and the shutdown function to stop it.
func StartScheduler(clientSet clientset.Interface, cfg *kubeschedulerconfig.KubeSchedulerConfiguration) (*scheduler.Scheduler, coreinformers.PodInformer, ShutdownFunc) {
func StartScheduler(clientSet clientset.Interface, kubeConfig *restclient.Config, cfg *kubeschedulerconfig.KubeSchedulerConfiguration) (*scheduler.Scheduler, coreinformers.PodInformer, ShutdownFunc) {
ctx, cancel := context.WithCancel(context.Background())
informerFactory := scheduler.NewInformerFactory(clientSet, 0)
@@ -89,6 +89,7 @@ func StartScheduler(clientSet clientset.Interface, cfg *kubeschedulerconfig.Kube
informerFactory,
profile.NewRecorderFactory(evtBroadcaster),
ctx.Done(),
scheduler.WithKubeConfig(kubeConfig),
scheduler.WithProfiles(cfg.Profiles...),
scheduler.WithAlgorithmSource(cfg.AlgorithmSource),
scheduler.WithPercentageOfNodesToScore(cfg.PercentageOfNodesToScore),
@@ -159,7 +160,8 @@ type TestContext struct {
CloseFn framework.CloseFunc
HTTPServer *httptest.Server
NS *v1.Namespace
ClientSet *clientset.Clientset
ClientSet clientset.Interface
KubeConfig *restclient.Config
InformerFactory informers.SharedInformerFactory
Scheduler *scheduler.Scheduler
Ctx context.Context
@@ -349,14 +351,14 @@ func InitTestMaster(t *testing.T, nsPrefix string, admission admission.Interface
}
// 2. Create kubeclient
testCtx.ClientSet = clientset.NewForConfigOrDie(
&restclient.Config{
QPS: -1, Host: s.URL,
ContentConfig: restclient.ContentConfig{
GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"},
},
kubeConfig := &restclient.Config{
QPS: -1, Host: s.URL,
ContentConfig: restclient.ContentConfig{
GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"},
},
)
}
testCtx.KubeConfig = kubeConfig
testCtx.ClientSet = clientset.NewForConfigOrDie(kubeConfig)
return &testCtx
}
@@ -403,6 +405,7 @@ func InitTestSchedulerWithOptions(
if policy != nil {
opts = append(opts, scheduler.WithAlgorithmSource(CreateAlgorithmSourceFromPolicy(policy, testCtx.ClientSet)))
}
opts = append(opts, scheduler.WithKubeConfig(testCtx.KubeConfig))
testCtx.Scheduler, err = scheduler.New(
testCtx.ClientSet,
testCtx.InformerFactory,