Merge pull request #117845 from ctripcloud/fix-hpa-plain-calc

fix HPA plain metric calculate
This commit is contained in:
Kubernetes Prow Robot 2023-06-30 01:51:47 -07:00 committed by GitHub
commit 9af93df9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -214,7 +214,7 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet
for podName := range missingPods {
metrics[podName] = metricsclient.PodMetric{Value: targetUsage}
}
} else {
} else if usageRatio > 1.0 {
// on a scale-up, treat missing pods as using 0% of the resource request
for podName := range missingPods {
metrics[podName] = metricsclient.PodMetric{Value: 0}

View File

@ -1322,6 +1322,21 @@ func TestReplicaCalcEmptyCPURequest(t *testing.T) {
tc.runTest(t)
}
func TestPlainMetricReplicaCalcMissingMetricsNoChangeEq(t *testing.T) {
tc := replicaCalcTestCase{
currentReplicas: 5,
expectedReplicas: 5,
metric: &metricInfo{
name: "qps",
levels: []int64{20000, 19000, 21000},
targetUsage: 20000,
expectedUsage: 20000,
metricType: podMetric,
},
}
tc.runTest(t)
}
func TestReplicaCalcMissingMetricsNoChangeEq(t *testing.T) {
tc := replicaCalcTestCase{
currentReplicas: 2,