FIX: hpa scale down with target >= 100
This commit is contained in:
parent
bcea98234f
commit
6bb73bae06
@ -105,9 +105,10 @@ func (c *ReplicaCalculator) GetResourceReplicas(ctx context.Context, currentRepl
|
|||||||
|
|
||||||
if len(missingPods) > 0 {
|
if len(missingPods) > 0 {
|
||||||
if usageRatio < 1.0 {
|
if usageRatio < 1.0 {
|
||||||
// on a scale-down, treat missing pods as using 100% of the resource request
|
// on a scale-down, treat missing pods as using 100% (all) of the resource request
|
||||||
|
maxTargetUtilization := int64(max(100, int32(targetUtilization)))
|
||||||
for podName := range missingPods {
|
for podName := range missingPods {
|
||||||
metrics[podName] = metricsclient.PodMetric{Value: requests[podName]}
|
metrics[podName] = metricsclient.PodMetric{Value: requests[podName] * maxTargetUtilization / 100}
|
||||||
}
|
}
|
||||||
} else if usageRatio > 1.0 {
|
} 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
|
||||||
@ -208,9 +209,10 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet
|
|||||||
|
|
||||||
if len(missingPods) > 0 {
|
if len(missingPods) > 0 {
|
||||||
if usageRatio < 1.0 {
|
if usageRatio < 1.0 {
|
||||||
// on a scale-down, treat missing pods as using 100% of the resource request
|
// on a scale-down, treat missing pods as using 100% (all) of the resource request
|
||||||
|
maxTargetUtilization := int64(max(100, int32(targetUtilization)))
|
||||||
for podName := range missingPods {
|
for podName := range missingPods {
|
||||||
metrics[podName] = metricsclient.PodMetric{Value: targetUtilization}
|
metrics[podName] = metricsclient.PodMetric{Value: maxTargetUtilization}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 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
|
||||||
|
Loading…
Reference in New Issue
Block a user