support scheduler_plugin_execution_duration_seconds in scheduler_perf

This commit is contained in:
Kensei Nakada
2024-04-27 08:07:56 +00:00
parent 8946348636
commit c72b688e12
4 changed files with 188 additions and 15 deletions

View File

@@ -53,6 +53,7 @@ import (
"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/pkg/scheduler/framework/plugins/names"
frameworkruntime "k8s.io/kubernetes/pkg/scheduler/framework/runtime"
"k8s.io/kubernetes/pkg/scheduler/metrics"
"k8s.io/kubernetes/test/integration/framework"
@@ -90,23 +91,65 @@ const (
configFile = "config/performance-config.yaml"
extensionPointsLabelName = "extension_point"
resultLabelName = "result"
pluginLabelName = "plugin"
)
var (
defaultMetricsCollectorConfig = metricsCollectorConfig{
Metrics: map[string]*labelValues{
Metrics: map[string][]*labelValues{
"scheduler_framework_extension_point_duration_seconds": {
label: extensionPointsLabelName,
values: []string{"Filter", "Score"},
{
label: extensionPointsLabelName,
values: metrics.ExtentionPoints,
},
},
"scheduler_scheduling_attempt_duration_seconds": {
label: resultLabelName,
values: []string{metrics.ScheduledResult, metrics.UnschedulableResult, metrics.ErrorResult},
{
label: resultLabelName,
values: []string{metrics.ScheduledResult, metrics.UnschedulableResult, metrics.ErrorResult},
},
},
"scheduler_pod_scheduling_duration_seconds": nil,
"scheduler_plugin_execution_duration_seconds": {
{
label: pluginLabelName,
values: PluginNames,
},
{
label: extensionPointsLabelName,
values: metrics.ExtentionPoints,
},
},
"scheduler_pod_scheduling_duration_seconds": nil,
"scheduler_pod_scheduling_sli_duration_seconds": nil,
},
}
// PluginNames is the names of the plugins that scheduler_perf collects metrics for.
// We export this variable because people outside k/k may want to put their custom plugins.
PluginNames = []string{
names.PrioritySort,
names.DefaultBinder,
names.DefaultPreemption,
names.DynamicResources,
names.ImageLocality,
names.InterPodAffinity,
names.NodeAffinity,
names.NodeName,
names.NodePorts,
names.NodeResourcesBalancedAllocation,
names.NodeResourcesFit,
names.NodeUnschedulable,
names.NodeVolumeLimits,
names.AzureDiskLimits,
names.CinderLimits,
names.EBSLimits,
names.GCEPDLimits,
names.PodTopologySpread,
names.SchedulingGates,
names.TaintToleration,
names.VolumeBinding,
names.VolumeRestrictions,
names.VolumeZone,
}
)
// testCase defines a set of test cases that intends to test the performance of
@@ -668,7 +711,9 @@ func withCleanup(tCtx ktesting.TContext, enabled bool) ktesting.TContext {
var perfSchedulingLabelFilter = flag.String("perf-scheduling-label-filter", "performance", "comma-separated list of labels which a testcase must have (no prefix or +) or must not have (-), used by BenchmarkPerfScheduling")
// RunBenchmarkPerfScheduling runs the scheduler performance tests.
// Optionally, you can pass your own scheduler plugin via outOfTreePluginRegistry.
//
// You can pass your own scheduler plugins via outOfTreePluginRegistry.
// Also, you may want to put your plugins in PluginNames variable in this package.
func RunBenchmarkPerfScheduling(b *testing.B, outOfTreePluginRegistry frameworkruntime.Registry) {
testCases, err := getTestCases(configFile)
if err != nil {