mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Enable scheduler_perf to support scheduler config file
Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
@@ -43,6 +43,9 @@ import (
|
||||
"k8s.io/component-base/featuregate"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/validation"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
testutils "k8s.io/kubernetes/test/utils"
|
||||
"sigs.k8s.io/yaml"
|
||||
@@ -91,6 +94,8 @@ type testCase struct {
|
||||
WorkloadTemplate []op
|
||||
// List of workloads to run under this testCase.
|
||||
Workloads []*workload
|
||||
// SchedulerConfigFile is the path of scheduler configuration
|
||||
SchedulerConfigFile string
|
||||
// TODO(#93792): reduce config toil by having a default pod and node spec per
|
||||
// testCase? CreatePods and CreateNodes ops will inherit these unless
|
||||
// manually overridden.
|
||||
@@ -372,11 +377,38 @@ func BenchmarkPerfScheduling(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func loadSchedulerConfig(file string) (*config.KubeSchedulerConfiguration, error) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// The UniversalDecoder runs defaulting and returns the internal type by default.
|
||||
obj, gvk, err := scheme.Codecs.UniversalDecoder().Decode(data, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cfgObj, ok := obj.(*config.KubeSchedulerConfiguration); ok {
|
||||
return cfgObj, nil
|
||||
}
|
||||
return nil, fmt.Errorf("couldn't decode as KubeSchedulerConfiguration, got %s: ", gvk)
|
||||
}
|
||||
|
||||
func runWorkload(b *testing.B, tc *testCase, w *workload) []DataItem {
|
||||
// 30 minutes should be plenty enough even for the 5000-node tests.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
||||
defer cancel()
|
||||
finalFunc, podInformer, client, dynClient := mustSetupScheduler()
|
||||
var cfg *config.KubeSchedulerConfiguration
|
||||
var err error
|
||||
if len(tc.SchedulerConfigFile) != 0 {
|
||||
cfg, err = loadSchedulerConfig(tc.SchedulerConfigFile)
|
||||
if err != nil {
|
||||
b.Fatalf("error loading scheduler config file: %v", err)
|
||||
}
|
||||
if err = validation.ValidateKubeSchedulerConfiguration(cfg).ToAggregate(); err != nil {
|
||||
b.Fatalf("validate scheduler config file failed: %v", err)
|
||||
}
|
||||
}
|
||||
finalFunc, podInformer, client, dynClient := mustSetupScheduler(cfg)
|
||||
b.Cleanup(finalFunc)
|
||||
|
||||
var mu sync.Mutex
|
||||
|
||||
Reference in New Issue
Block a user