Skip to content

Commit 0eeaee6

Browse files
author
mervynwang
committed
fix cpu recommend zero
1 parent 1a48e08 commit 0eeaee6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pkg/prediction/percentile/prediction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (p *percentilePrediction) getPredictedValuesFromSignals(queryExpr string, s
7171

7272
if cfg.aggregated {
7373
signal := signals[keyAll]
74-
if signal != nil {
74+
if signal != nil && signal.totalSamplesCount > 0 {
7575
sample := common.Sample{
7676
Value: estimator.GetEstimation(signal.histogram),
7777
Timestamp: now,

pkg/recommendation/recommender/resource/recommend.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ func (rr *ResourceRecommender) Recommend(ctx *framework.RecommendationContext) e
131131
pr.Target[corev1.ResourceMemory] = memQuantity.String()
132132
}
133133

134-
resourceRecommendation.Pod = &pr
134+
if len(pr.Target) != 0 {
135+
resourceRecommendation.Pod = &pr
136+
}
135137
} else {
136138
klog.V(4).Infof("not use pod metrics for pod %s", ctx.Pods[0].Name)
137139
}

0 commit comments

Comments
 (0)