mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 16:06:51 +00:00
GetObjectMetricReplicas ignores unready pods
Previously, when `GetObjectMetricReplicas` calculated the desired replica count, it multiplied the usage ratio by the current number of replicas. This method caused over-scaling when there were pods that were not ready for a long period of time. For example, if there were pods A, B, and C, and only pod A was ready, and the usage ratio was 500%, we would previously specify 15 pods as the desired replicas (even though really only one pod was handling the load). After this change, we now multiple the usage ratio by the number of ready pods for `GetObjectMetricReplicas`. In the example above, we'd only desire 5 replica pods. This change gives `GetObjectMetricReplicas` the same behavior as the other replica calculator methods. Only `GetExternalMetricReplicas` and `GetExternalPerPodMetricRepliacs` still allow unready pods to impact the number of desired replicas. I will fix this issue in the following commit.
This commit is contained in:
@@ -223,7 +223,7 @@ func (a *HorizontalController) computeReplicasForMetrics(hpa *autoscalingv2.Hori
|
||||
|
||||
switch metricSpec.Type {
|
||||
case autoscalingv2.ObjectMetricSourceType:
|
||||
replicaCountProposal, utilizationProposal, timestampProposal, err = a.replicaCalc.GetObjectMetricReplicas(currentReplicas, metricSpec.Object.TargetValue.MilliValue(), metricSpec.Object.MetricName, hpa.Namespace, &metricSpec.Object.Target)
|
||||
replicaCountProposal, utilizationProposal, timestampProposal, err = a.replicaCalc.GetObjectMetricReplicas(currentReplicas, metricSpec.Object.TargetValue.MilliValue(), metricSpec.Object.MetricName, hpa.Namespace, &metricSpec.Object.Target, selector)
|
||||
if err != nil {
|
||||
a.eventRecorder.Event(hpa, v1.EventTypeWarning, "FailedGetObjectMetric", err.Error())
|
||||
setCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, "FailedGetObjectMetric", "the HPA was unable to compute the replica count: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user