mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 13:12:20 +00:00
Fixed panic in GCM data source implementation in Initial Resources
The panic occured when there was no historical data to make prediction
This commit is contained in:
@@ -122,6 +122,9 @@ func (s *gcmSource) GetUsagePercentile(kind api.ResourceName, perc int64, image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
count := len(rawSamples)
|
count := len(rawSamples)
|
||||||
|
if count == 0 {
|
||||||
|
return 0, 0, nil
|
||||||
|
}
|
||||||
sort.Ints(rawSamples)
|
sort.Ints(rawSamples)
|
||||||
usageIndex := int64(math.Ceil(float64(count)*9/10)) - 1
|
usageIndex := int64(math.Ceil(float64(count)*9/10)) - 1
|
||||||
usage := rawSamples[usageIndex]
|
usage := rawSamples[usageIndex]
|
||||||
|
Reference in New Issue
Block a user