mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
scheduler_perf: refactor to allow arbitrary workloads
Signed-off-by: Adhityaa Chandrasekar <adtac@google.com>
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package benchmark
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
@@ -147,18 +148,18 @@ type metricsCollectorConfig struct {
|
||||
// metricsCollector collects metrics from legacyregistry.DefaultGatherer.Gather() endpoint.
|
||||
// Currently only Histrogram metrics are supported.
|
||||
type metricsCollector struct {
|
||||
metricsCollectorConfig
|
||||
*metricsCollectorConfig
|
||||
labels map[string]string
|
||||
}
|
||||
|
||||
func newMetricsCollector(config metricsCollectorConfig, labels map[string]string) *metricsCollector {
|
||||
func newMetricsCollector(config *metricsCollectorConfig, labels map[string]string) *metricsCollector {
|
||||
return &metricsCollector{
|
||||
metricsCollectorConfig: config,
|
||||
labels: labels,
|
||||
}
|
||||
}
|
||||
|
||||
func (*metricsCollector) run(stopCh chan struct{}) {
|
||||
func (*metricsCollector) run(ctx context.Context) {
|
||||
// metricCollector doesn't need to start before the tests, so nothing to do here.
|
||||
}
|
||||
|
||||
@@ -231,7 +232,7 @@ func newThroughputCollector(podInformer coreinformers.PodInformer, labels map[st
|
||||
}
|
||||
}
|
||||
|
||||
func (tc *throughputCollector) run(stopCh chan struct{}) {
|
||||
func (tc *throughputCollector) run(ctx context.Context) {
|
||||
podsScheduled, err := getScheduledPods(tc.podInformer, tc.namespaces...)
|
||||
if err != nil {
|
||||
klog.Fatalf("%v", err)
|
||||
@@ -239,8 +240,9 @@ func (tc *throughputCollector) run(stopCh chan struct{}) {
|
||||
lastScheduledCount := len(podsScheduled)
|
||||
for {
|
||||
select {
|
||||
case <-stopCh:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
// TODO(#94665): use time.Ticker instead
|
||||
case <-time.After(throughputSampleFrequency):
|
||||
podsScheduled, err := getScheduledPods(tc.podInformer, tc.namespaces...)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user