add if check for number of scheduled pods to be greater than 0

This commit is contained in:
Alexander Minbaev 2021-03-05 09:05:42 -06:00
parent 55f255208a
commit 359116f525

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)
}
}
}