mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #78725 from waynepeking348/waynepeking348-master
fix bug of replica_calculator to initialize replicaCount with currentReplicas
This commit is contained in:
commit
602fc4771a
@ -265,6 +265,7 @@ func (c *ReplicaCalculator) GetObjectPerPodMetricReplicas(currentReplicas int32,
|
|||||||
return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v on %s %s/%s", metricName, objectRef.Kind, namespace, objectRef.Name, err)
|
return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v on %s %s/%s", metricName, objectRef.Kind, namespace, objectRef.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
replicaCount = currentReplicas
|
||||||
usageRatio := float64(utilization) / (float64(targetAverageUtilization) * float64(replicaCount))
|
usageRatio := float64(utilization) / (float64(targetAverageUtilization) * float64(replicaCount))
|
||||||
if math.Abs(1.0-usageRatio) > c.tolerance {
|
if math.Abs(1.0-usageRatio) > c.tolerance {
|
||||||
// update number of replicas if change is large enough
|
// update number of replicas if change is large enough
|
||||||
|
@ -970,6 +970,26 @@ func TestReplicaCalcToleranceCMObject(t *testing.T) {
|
|||||||
tc.runTest(t)
|
tc.runTest(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReplicaCalcTolerancePerPodCMObject(t *testing.T) {
|
||||||
|
tc := replicaCalcTestCase{
|
||||||
|
currentReplicas: 4,
|
||||||
|
expectedReplicas: 4,
|
||||||
|
metric: &metricInfo{
|
||||||
|
metricType: objectPerPodMetric,
|
||||||
|
name: "qps",
|
||||||
|
levels: []int64{20166},
|
||||||
|
perPodTargetUtilization: 5000,
|
||||||
|
expectedUtilization: 5042,
|
||||||
|
singleObject: &autoscalingv2.CrossVersionObjectReference{
|
||||||
|
Kind: "Deployment",
|
||||||
|
APIVersion: "apps/v1",
|
||||||
|
Name: "some-deployment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
tc.runTest(t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestReplicaCalcToleranceCMExternal(t *testing.T) {
|
func TestReplicaCalcToleranceCMExternal(t *testing.T) {
|
||||||
tc := replicaCalcTestCase{
|
tc := replicaCalcTestCase{
|
||||||
currentReplicas: 3,
|
currentReplicas: 3,
|
||||||
|
Loading…
Reference in New Issue
Block a user