mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #15074 from piosz/initial-fix
Fixed few issues with Initial Resources
This commit is contained in:
commit
acb9db6e2f
@ -39,7 +39,7 @@ var (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
initialResourcesAnnotation = "kubernetes.io/initial-resources"
|
initialResourcesAnnotation = "kubernetes.io/initial-resources"
|
||||||
samplesThreshold = 60
|
samplesThreshold = 30
|
||||||
week = 7 * 24 * time.Hour
|
week = 7 * 24 * time.Hour
|
||||||
month = 30 * 24 * time.Hour
|
month = 30 * 24 * time.Hour
|
||||||
)
|
)
|
||||||
|
@ -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]
|
||||||
|
@ -27,10 +27,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
cpuSeriesName = "autoscaling.cpu.usage.1m"
|
cpuSeriesName = "autoscaling.cpu.usage.2m"
|
||||||
memSeriesName = "autoscaling.memory.usage.1m"
|
memSeriesName = "autoscaling.memory.usage.2m"
|
||||||
cpuContinuousQuery = "select derivative(value) as value from \"cpu/usage_ns_cumulative\" where pod_id <> '' group by pod_id, pod_namespace, container_name, container_base_image, time(1m) into " + cpuSeriesName
|
cpuContinuousQuery = "select derivative(value) as value from \"cpu/usage_ns_cumulative\" where pod_id <> '' group by pod_id, pod_namespace, container_name, container_base_image, time(2m) into " + cpuSeriesName
|
||||||
memContinuousQuery = "select mean(value) as value from \"memory/usage_bytes_gauge\" where pod_id <> '' group by pod_id, pod_namespace, container_name, container_base_image, time(1m) into " + memSeriesName
|
memContinuousQuery = "select mean(value) as value from \"memory/usage_bytes_gauge\" where pod_id <> '' group by pod_id, pod_namespace, container_name, container_base_image, time(2m) into " + memSeriesName
|
||||||
timeFormat = "2006-01-02 15:04:05"
|
timeFormat = "2006-01-02 15:04:05"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -124,7 +124,8 @@ func (s *influxdbSource) GetUsagePercentile(kind api.ResourceName, perc int64, i
|
|||||||
if exactMatch {
|
if exactMatch {
|
||||||
imgPattern = "='" + image + "'"
|
imgPattern = "='" + image + "'"
|
||||||
} else {
|
} else {
|
||||||
imgPattern = "=~/^" + image + "/"
|
// Escape character "/" in image pattern.
|
||||||
|
imgPattern = "=~/^" + strings.Replace(image, "/", "\\/", -1) + "/"
|
||||||
}
|
}
|
||||||
var namespaceCond string
|
var namespaceCond string
|
||||||
if namespace != "" {
|
if namespace != "" {
|
||||||
@ -140,7 +141,7 @@ func (s *influxdbSource) GetUsagePercentile(kind api.ResourceName, perc int64, i
|
|||||||
|
|
||||||
// TODO(pszczesniak): fix issue with dropped data base
|
// TODO(pszczesniak): fix issue with dropped data base
|
||||||
if len(res) == 0 {
|
if len(res) == 0 {
|
||||||
return 0, 0, fmt.Errorf("Missing series %v in InfluxDB", series)
|
return 0, 0, fmt.Errorf("Missing data in series %v in InfluxDB", series)
|
||||||
}
|
}
|
||||||
points := res[0].GetPoints()
|
points := res[0].GetPoints()
|
||||||
if len(points) == 0 {
|
if len(points) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user