Merge pull request #119048 from pohly/scheduler-perf-metrics-for-perfdash

scheduler-perf: metrics for perfdash
This commit is contained in:
Kubernetes Prow Robot 2023-07-09 09:27:04 -07:00 committed by GitHub
commit d653dcab5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -996,7 +996,10 @@ func runWorkload(ctx context.Context, tb testing.TB, tc *testCase, w *workload,
if concreteOp.CollectMetrics {
collectorCtx, collectorCancel = context.WithCancel(ctx)
defer collectorCancel()
collectors = getTestDataCollectors(tb, podInformer, fmt.Sprintf("%s/%s", tb.Name(), namespace), namespace, tc.MetricsCollectorConfig, throughputErrorMargin)
name := tb.Name()
// The first part is the same for each work load, therefore we can strip it.
name = name[strings.Index(name, "/")+1:]
collectors = getTestDataCollectors(tb, podInformer, fmt.Sprintf("%s/%s", name, namespace), namespace, tc.MetricsCollectorConfig, throughputErrorMargin)
for _, collector := range collectors {
// Need loop-local variable for function below.
collector := collector

View File

@ -196,6 +196,27 @@ func makeBasePod() *v1.Pod {
}
func dataItems2JSONFile(dataItems DataItems, namePrefix string) error {
// perfdash expects all data items to have the same set of labels. It
// then renders drop-down buttons for each label with all values found
// for each label. If we were to store data items that don't have a
// certain label, then perfdash will never show those data items
// because it will only show data items that have the currently
// selected label value. To avoid that, we collect all labels used
// anywhere and then add missing labels with "not applicable" as value.
labels := sets.New[string]()
for _, item := range dataItems.DataItems {
for label := range item.Labels {
labels.Insert(label)
}
}
for _, item := range dataItems.DataItems {
for label := range labels {
if _, ok := item.Labels[label]; !ok {
item.Labels[label] = "not applicable"
}
}
}
b, err := json.Marshal(dataItems)
if err != nil {
return err