mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
fix HPA plain metric calculate
fix inconsistency in plain metric replica calculator when usageRatio == 1.0, keep same with resource replicas
This commit is contained in:
parent
6aa68d6a8b
commit
e3d5feb76c
@ -214,7 +214,7 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet
|
|||||||
for podName := range missingPods {
|
for podName := range missingPods {
|
||||||
metrics[podName] = metricsclient.PodMetric{Value: targetUsage}
|
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
|
// on a scale-up, treat missing pods as using 0% of the resource request
|
||||||
for podName := range missingPods {
|
for podName := range missingPods {
|
||||||
metrics[podName] = metricsclient.PodMetric{Value: 0}
|
metrics[podName] = metricsclient.PodMetric{Value: 0}
|
||||||
|
@ -1322,6 +1322,21 @@ func TestReplicaCalcEmptyCPURequest(t *testing.T) {
|
|||||||
tc.runTest(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) {
|
func TestReplicaCalcMissingMetricsNoChangeEq(t *testing.T) {
|
||||||
tc := replicaCalcTestCase{
|
tc := replicaCalcTestCase{
|
||||||
currentReplicas: 2,
|
currentReplicas: 2,
|
||||||
|
Loading…
Reference in New Issue
Block a user