Merge pull request #117197 from pohly/scheduler-perf-cleanup

scheduler perf: remove cleanup func
This commit is contained in:
Kubernetes Prow Robot 2023-04-11 21:17:57 -07:00 committed by GitHub
commit 2bfaaf21c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -750,8 +750,7 @@ func runWorkload(ctx context.Context, b *testing.B, tc *testCase, w *workload) [
b.Fatalf("validate scheduler config file failed: %v", err)
}
}
finalFunc, podInformer, client, dynClient := mustSetupScheduler(ctx, b, cfg)
b.Cleanup(finalFunc)
podInformer, client, dynClient := mustSetupScheduler(ctx, b, cfg)
var mu sync.Mutex
var dataItems []DataItem

View File

@ -75,8 +75,7 @@ func newDefaultComponentConfig() (*config.KubeSchedulerConfiguration, error) {
// remove resources after finished.
// Notes on rate limiter:
// - client rate limit is set to 5000.
func mustSetupScheduler(ctx context.Context, b *testing.B, config *config.KubeSchedulerConfiguration) (util.ShutdownFunc, coreinformers.PodInformer, clientset.Interface, dynamic.Interface) {
ctx, cancel := context.WithCancel(ctx)
func mustSetupScheduler(ctx context.Context, b *testing.B, config *config.KubeSchedulerConfiguration) (coreinformers.PodInformer, clientset.Interface, dynamic.Interface) {
// Run API server with minimimal logging by default. Can be raised with -v.
framework.MinVerbosity = 0
@ -86,6 +85,12 @@ func mustSetupScheduler(ctx context.Context, b *testing.B, config *config.KubeSc
opts.Admission.GenericAdmission.DisablePlugins = []string{"ServiceAccount", "TaintNodesByCondition", "Priority"}
},
})
b.Cleanup(tearDownFn)
// Cleanup will be in reverse order: first the clients get cancelled,
// then the apiserver is torn down.
ctx, cancel := context.WithCancel(ctx)
b.Cleanup(cancel)
// TODO: client connection configuration, such as QPS or Burst is configurable in theory, this could be derived from the `config`, need to
// support this when there is any testcase that depends on such configuration.
@ -110,12 +115,7 @@ func mustSetupScheduler(ctx context.Context, b *testing.B, config *config.KubeSc
_, podInformer := util.StartScheduler(ctx, client, cfg, config)
util.StartFakePVController(ctx, client)
shutdownFn := func() {
cancel()
tearDownFn()
}
return shutdownFn, podInformer, client, dynClient
return podInformer, client, dynClient
}
// Returns the list of scheduled pods in the specified namespaces.