@@ -998,15 +998,17 @@ func calculateScaleUpLimitWithScalingRules(currentReplicas int32, scaleEvents []
998
998
if * scalingRules .SelectPolicy == autoscalingv2 .DisabledPolicySelect {
999
999
return currentReplicas // Scaling is disabled
1000
1000
} else if * scalingRules .SelectPolicy == autoscalingv2 .MinPolicySelect {
1001
+ result = math .MaxInt32
1001
1002
selectPolicyFn = min // For scaling up, the lowest change ('min' policy) produces a minimum value
1002
1003
} else {
1004
+ result = math .MinInt32
1003
1005
selectPolicyFn = max // Use the default policy otherwise to produce a highest possible change
1004
1006
}
1005
1007
for _ , policy := range scalingRules .Policies {
1006
1008
replicasAddedInCurrentPeriod := getReplicasChangePerPeriod (policy .PeriodSeconds , scaleEvents )
1007
1009
periodStartReplicas := currentReplicas - replicasAddedInCurrentPeriod
1008
1010
if policy .Type == autoscalingv2 .PodsScalingPolicy {
1009
- proposed = int32 ( periodStartReplicas + policy .Value )
1011
+ proposed = periodStartReplicas + policy .Value
1010
1012
} else if policy .Type == autoscalingv2 .PercentScalingPolicy {
1011
1013
// the proposal has to be rounded up because the proposed change might not increase the replica count causing the target to never scale up
1012
1014
proposed = int32 (math .Ceil (float64 (periodStartReplicas ) * (1 + float64 (policy .Value )/ 100 )))
@@ -1018,14 +1020,16 @@ func calculateScaleUpLimitWithScalingRules(currentReplicas int32, scaleEvents []
1018
1020
1019
1021
// calculateScaleDownLimitWithBehavior returns the maximum number of pods that could be deleted for the given HPAScalingRules
1020
1022
func calculateScaleDownLimitWithBehaviors (currentReplicas int32 , scaleEvents []timestampedScaleEvent , scalingRules * autoscalingv2.HPAScalingRules ) int32 {
1021
- var result int32 = math . MaxInt32
1023
+ var result int32
1022
1024
var proposed int32
1023
1025
var selectPolicyFn func (int32 , int32 ) int32
1024
1026
if * scalingRules .SelectPolicy == autoscalingv2 .DisabledPolicySelect {
1025
1027
return currentReplicas // Scaling is disabled
1026
1028
} else if * scalingRules .SelectPolicy == autoscalingv2 .MinPolicySelect {
1029
+ result = math .MinInt32
1027
1030
selectPolicyFn = max // For scaling down, the lowest change ('min' policy) produces a maximum value
1028
1031
} else {
1032
+ result = math .MaxInt32
1029
1033
selectPolicyFn = min // Use the default policy otherwise to produce a highest possible change
1030
1034
}
1031
1035
for _ , policy := range scalingRules .Policies {
0 commit comments