Skip to content

Commit 2bb886c

Browse files
authored
Merge pull request kubernetes#128482 from sanposhiho/scheduler-perf-ff
fix: register QHint metrics only when available
2 parents 033b275 + 0bf9510 commit 2bb886c

File tree

1 file changed

+48
-24
lines changed

1 file changed

+48
-24
lines changed

test/integration/scheduler_perf/scheduler_perf.go

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,24 @@ var (
160160
values: metrics.ExtentionPoints,
161161
},
162162
},
163-
"scheduler_queueing_hint_execution_duration_seconds": {
164-
{
165-
label: pluginLabelName,
166-
values: PluginNames,
167-
},
168-
{
169-
label: eventLabelName,
170-
values: schedframework.AllClusterEventLabels(),
171-
},
163+
},
164+
}
165+
166+
qHintMetrics = map[string][]*labelValues{
167+
"scheduler_queueing_hint_execution_duration_seconds": {
168+
{
169+
label: pluginLabelName,
170+
values: PluginNames,
172171
},
173-
"scheduler_event_handling_duration_seconds": {
174-
{
175-
label: eventLabelName,
176-
values: schedframework.AllClusterEventLabels(),
177-
},
172+
{
173+
label: eventLabelName,
174+
values: schedframework.AllClusterEventLabels(),
175+
},
176+
},
177+
"scheduler_event_handling_duration_seconds": {
178+
{
179+
label: eventLabelName,
180+
values: schedframework.AllClusterEventLabels(),
178181
},
179182
},
180183
}
@@ -245,6 +248,18 @@ func InitTests() error {
245248
return logsapi.ValidateAndApply(LoggingConfig, LoggingFeatureGate)
246249
}
247250

251+
func registerQHintMetrics() {
252+
for k, v := range qHintMetrics {
253+
defaultMetricsCollectorConfig.Metrics[k] = v
254+
}
255+
}
256+
257+
func unregisterQHintMetrics() {
258+
for k := range qHintMetrics {
259+
delete(defaultMetricsCollectorConfig.Metrics, k)
260+
}
261+
}
262+
248263
// testCase defines a set of test cases that intends to test the performance of
249264
// similar workloads of varying sizes with shared overall settings such as
250265
// feature gates and metrics collected.
@@ -1056,7 +1071,6 @@ func setupTestCase(t testing.TB, tc *testCase, featureGates map[featuregate.Feat
10561071
if err := logsapi.ValidateAndApplyWithOptions(LoggingConfig, opts, LoggingFeatureGate); err != nil {
10571072
t.Fatalf("Failed to apply the per-test logging configuration: %v", err)
10581073
}
1059-
10601074
}
10611075

10621076
// Ensure that there are no leaked
@@ -1080,6 +1094,13 @@ func setupTestCase(t testing.TB, tc *testCase, featureGates map[featuregate.Feat
10801094
timeout := 30 * time.Minute
10811095
tCtx = ktesting.WithTimeout(tCtx, timeout, fmt.Sprintf("timed out after the %s per-test timeout", timeout))
10821096

1097+
if utilfeature.DefaultFeatureGate.Enabled(features.SchedulerQueueingHints) {
1098+
registerQHintMetrics()
1099+
t.Cleanup(func() {
1100+
unregisterQHintMetrics()
1101+
})
1102+
}
1103+
10831104
return setupClusterForWorkload(tCtx, tc.SchedulerConfigPath, featureGates, outOfTreePluginRegistry)
10841105
}
10851106

@@ -1135,6 +1156,14 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
11351156
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
11361157
informerFactory, tCtx := setupTestCase(b, tc, featureGates, output, outOfTreePluginRegistry)
11371158

1159+
// TODO(#93795): make sure each workload within a test case has a unique
1160+
// name? The name is used to identify the stats in benchmark reports.
1161+
// TODO(#94404): check for unused template parameters? Probably a typo.
1162+
err := w.isValid(tc.MetricsCollectorConfig)
1163+
if err != nil {
1164+
b.Fatalf("workload %s is not valid: %v", w.Name, err)
1165+
}
1166+
11381167
results := runWorkload(tCtx, tc, w, informerFactory)
11391168
dataItems.DataItems = append(dataItems.DataItems, results...)
11401169

@@ -1228,6 +1257,10 @@ func RunIntegrationPerfScheduling(t *testing.T, configFile string) {
12281257
}
12291258
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
12301259
informerFactory, tCtx := setupTestCase(t, tc, featureGates, nil, nil)
1260+
err := w.isValid(tc.MetricsCollectorConfig)
1261+
if err != nil {
1262+
t.Fatalf("workload %s is not valid: %v", w.Name, err)
1263+
}
12311264

12321265
runWorkload(tCtx, tc, w, informerFactory)
12331266

@@ -2145,15 +2178,6 @@ func validateTestCases(testCases []*testCase) error {
21452178
if !tc.collectsMetrics() {
21462179
return fmt.Errorf("%s: no op in the workload template collects metrics", tc.Name)
21472180
}
2148-
// TODO(#93795): make sure each workload within a test case has a unique
2149-
// name? The name is used to identify the stats in benchmark reports.
2150-
// TODO(#94404): check for unused template parameters? Probably a typo.
2151-
for _, w := range tc.Workloads {
2152-
err := w.isValid(tc.MetricsCollectorConfig)
2153-
if err != nil {
2154-
return err
2155-
}
2156-
}
21572181
}
21582182
return nil
21592183
}

0 commit comments

Comments
 (0)