Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koordlet: fix misleading query helper #1893

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/koordlet/qosmanager/helpers/metrics_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func CollectContainerThrottledMetric(metricCache metriccache.MetricCache, contai
return aggregateResult, nil
}

func GenerateQueryParamsAvg(windowSeconds int64) *metriccache.QueryParam {
func GenerateQueryParamsAvg(windowDuration time.Duration) *metriccache.QueryParam {
end := time.Now()
start := end.Add(-time.Duration(windowSeconds) * time.Second)
start := end.Add(-windowDuration)
queryParam := &metriccache.QueryParam{
Aggregate: metriccache.AggregationTypeAVG,
Start: &start,
Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (b *cpuBurst) start() {
// return isOverload, share pool usage ratio and message detail
func (b *cpuBurst) getNodeStateForBurst(sharePoolThresholdPercent int64,
podsMeta []*statesinformer.PodMeta) nodeStateForBurst {
overloadMetricDuration := util.MinInt64(int64(b.reconcileInterval*5), int64(10*time.Second))
overloadMetricDuration := time.Duration(util.MinInt64(int64(b.reconcileInterval*5), int64(10*time.Second)))
queryParam := helpers.GenerateQueryParamsAvg(overloadMetricDuration)

queryMeta, err := metriccache.NodeCPUUsageMetric.BuildQueryMeta(nil)
Expand Down
20 changes: 10 additions & 10 deletions pkg/koordlet/qosmanager/plugins/cpuevict/cpu_evict.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ func (c *cpuEvictor) cpuEvict() {

func (c *cpuEvictor) calculateMilliRelease(thresholdConfig *slov1alpha1.ResourceThresholdStrategy, windowSeconds int64) int64 {
// Step1: Calculate release resource by BECPUResourceMetric in window
queryparam := helpers.GenerateQueryParamsAvg(windowSeconds)
querier, err := c.metricCache.Querier(*queryparam.Start, *queryparam.End)
queryParam := helpers.GenerateQueryParamsAvg(time.Duration(windowSeconds) * time.Second)
querier, err := c.metricCache.Querier(*queryParam.Start, *queryParam.End)
if err != nil {
klog.Warningf("get query failed, error %v", err)
return 0
}
// BECPUUsage
avgBECPUMilliUsage, count01 := getBECPUMetric(metriccache.BEResourceAllocationUsage, querier, queryparam.Aggregate)
avgBECPUMilliUsage, count01 := getBECPUMetric(metriccache.BEResourceAllocationUsage, querier, queryParam.Aggregate)
// BECPURequest
avgBECPUMilliRequest, count02 := getBECPUMetric(metriccache.BEResourceAllocationRequest, querier, queryparam.Aggregate)
avgBECPUMilliRequest, count02 := getBECPUMetric(metriccache.BEResourceAllocationRequest, querier, queryParam.Aggregate)
// BECPULimit
avgBECPUMilliRealLimit, count03 := getBECPUMetric(metriccache.BEResourceAllocationRealLimit, querier, queryparam.Aggregate)
avgBECPUMilliRealLimit, count03 := getBECPUMetric(metriccache.BEResourceAllocationRealLimit, querier, queryParam.Aggregate)

// CPU Satisfaction considers the allocatable when policy=evictByAllocatable.
avgBECPUMilliLimit := avgBECPUMilliRealLimit
Expand Down Expand Up @@ -172,18 +172,18 @@ func (c *cpuEvictor) calculateMilliRelease(thresholdConfig *slov1alpha1.Resource
}

// Step2: Calculate release resource current
queryparam = helpers.GenerateQueryParamsLast(c.metricCollectInterval * 2)
querier, err = c.metricCache.Querier(*queryparam.Start, *queryparam.End)
queryParam = helpers.GenerateQueryParamsLast(c.metricCollectInterval * 2)
querier, err = c.metricCache.Querier(*queryParam.Start, *queryParam.End)
if err != nil {
klog.Warningf("get query failed, error %v", err)
return 0
}
// BECPUUsage
currentBECPUMilliUsage, _ := getBECPUMetric(metriccache.BEResourceAllocationUsage, querier, queryparam.Aggregate)
currentBECPUMilliUsage, _ := getBECPUMetric(metriccache.BEResourceAllocationUsage, querier, queryParam.Aggregate)
// BECPURequest
currentBECPUMilliRequest, _ := getBECPUMetric(metriccache.BEResourceAllocationRequest, querier, queryparam.Aggregate)
currentBECPUMilliRequest, _ := getBECPUMetric(metriccache.BEResourceAllocationRequest, querier, queryParam.Aggregate)
// BECPULimit
currentBECPUMilliRealLimit, _ := getBECPUMetric(metriccache.BEResourceAllocationRealLimit, querier, queryparam.Aggregate)
currentBECPUMilliRealLimit, _ := getBECPUMetric(metriccache.BEResourceAllocationRealLimit, querier, queryParam.Aggregate)

// CPU Satisfaction considers the allocatable when policy=evictByAllocatable.
currentBECPUMilliLimit := currentBECPUMilliRealLimit
Expand Down
Loading