mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
scheduler perf: remove cleanup func
b.Cleanup may as well get called inside the function instead of leaving that to the caller.
This commit is contained in:
parent
ad18954259
commit
a869a89825
@ -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)
|
b.Fatalf("validate scheduler config file failed: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finalFunc, podInformer, client, dynClient := mustSetupScheduler(ctx, b, cfg)
|
podInformer, client, dynClient := mustSetupScheduler(ctx, b, cfg)
|
||||||
b.Cleanup(finalFunc)
|
|
||||||
|
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
var dataItems []DataItem
|
var dataItems []DataItem
|
||||||
|
@ -75,8 +75,7 @@ func newDefaultComponentConfig() (*config.KubeSchedulerConfiguration, error) {
|
|||||||
// remove resources after finished.
|
// remove resources after finished.
|
||||||
// Notes on rate limiter:
|
// Notes on rate limiter:
|
||||||
// - client rate limit is set to 5000.
|
// - 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) {
|
func mustSetupScheduler(ctx context.Context, b *testing.B, config *config.KubeSchedulerConfiguration) (coreinformers.PodInformer, clientset.Interface, dynamic.Interface) {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
|
||||||
// Run API server with minimimal logging by default. Can be raised with -v.
|
// Run API server with minimimal logging by default. Can be raised with -v.
|
||||||
framework.MinVerbosity = 0
|
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"}
|
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
|
// 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.
|
// 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)
|
_, podInformer := util.StartScheduler(ctx, client, cfg, config)
|
||||||
util.StartFakePVController(ctx, client)
|
util.StartFakePVController(ctx, client)
|
||||||
|
|
||||||
shutdownFn := func() {
|
return podInformer, client, dynClient
|
||||||
cancel()
|
|
||||||
tearDownFn()
|
|
||||||
}
|
|
||||||
|
|
||||||
return shutdownFn, podInformer, client, dynClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the list of scheduled pods in the specified namespaces.
|
// Returns the list of scheduled pods in the specified namespaces.
|
||||||
|
Loading…
Reference in New Issue
Block a user