Merge pull request #99844 from minbaev/scheduler-test-perf-optimization

add if check for number of scheduled pods to be greater than 0
This commit is contained in:
Kubernetes Prow Robot 2021-03-08 20:47:37 -08:00 committed by GitHub
commit 841cb4adc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,12 +256,15 @@ func (tc *throughputCollector) run(ctx context.Context) {
}
scheduled := len(podsScheduled)
samplingRatioSeconds := float64(throughputSampleFrequency) / float64(time.Second)
throughput := float64(scheduled-lastScheduledCount) / samplingRatioSeconds
tc.schedulingThroughputs = append(tc.schedulingThroughputs, throughput)
lastScheduledCount = scheduled
// Only do sampling if number of scheduled pods is greater than zero
if scheduled > 0 {
samplingRatioSeconds := float64(throughputSampleFrequency) / float64(time.Second)
throughput := float64(scheduled-lastScheduledCount) / samplingRatioSeconds
tc.schedulingThroughputs = append(tc.schedulingThroughputs, throughput)
lastScheduledCount = scheduled
klog.Infof("%d pods scheduled", lastScheduledCount)
}
klog.Infof("%d pods scheduled", lastScheduledCount)
}
}
}