Merge pull request #15074 from piosz/initial-fix

Fixed few issues with Initial Resources
pull/6/head
Marcin Wielgus 2015-10-05 17:03:31 +02:00
commit acb9db6e2f
3 changed files with 11 additions and 7 deletions

View File

@ -39,7 +39,7 @@ var (
const (
initialResourcesAnnotation = "kubernetes.io/initial-resources"
samplesThreshold = 60
samplesThreshold = 30
week = 7 * 24 * time.Hour
month = 30 * 24 * time.Hour
)

View File

@ -122,6 +122,9 @@ func (s *gcmSource) GetUsagePercentile(kind api.ResourceName, perc int64, image,
}
count := len(rawSamples)
if count == 0 {
return 0, 0, nil
}
sort.Ints(rawSamples)
usageIndex := int64(math.Ceil(float64(count)*9/10)) - 1
usage := rawSamples[usageIndex]

View File

@ -27,10 +27,10 @@ import (
)
const (
cpuSeriesName = "autoscaling.cpu.usage.1m"
memSeriesName = "autoscaling.memory.usage.1m"
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
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
cpuSeriesName = "autoscaling.cpu.usage.2m"
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(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(2m) into " + memSeriesName
timeFormat = "2006-01-02 15:04:05"
)
@ -124,7 +124,8 @@ func (s *influxdbSource) GetUsagePercentile(kind api.ResourceName, perc int64, i
if exactMatch {
imgPattern = "='" + image + "'"
} else {
imgPattern = "=~/^" + image + "/"
// Escape character "/" in image pattern.
imgPattern = "=~/^" + strings.Replace(image, "/", "\\/", -1) + "/"
}
var namespaceCond string
if namespace != "" {
@ -140,7 +141,7 @@ func (s *influxdbSource) GetUsagePercentile(kind api.ResourceName, perc int64, i
// TODO(pszczesniak): fix issue with dropped data base
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()
if len(points) == 0 {