mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +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)
|
||||
}
|
||||
|
||||
replicaCount = currentReplicas
|
||||
usageRatio := float64(utilization) / (float64(targetAverageUtilization) * float64(replicaCount))
|
||||
if math.Abs(1.0-usageRatio) > c.tolerance {
|
||||
// update number of replicas if change is large enough
|
||||
|
@ -970,6 +970,26 @@ func TestReplicaCalcToleranceCMObject(t *testing.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) {
|
||||
tc := replicaCalcTestCase{
|
||||
currentReplicas: 3,
|
||||
|
Loading…
Reference in New Issue
Block a user