mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
If we set SelectPolicy MinPolicySelect on scaleUp behavior or scaleDown behavior,Horizontal Pod Autoscaler doesn`t automatically scale the number of pods correctly
Signed-off-by: weiwei <weiwei@tenxcloud.com>
This commit is contained in:
@@ -2993,6 +2993,50 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalculateScaleUpLimitWithScalingRules(t *testing.T) {
|
||||
policy := autoscalingv2.MinPolicySelect
|
||||
|
||||
calculated := calculateScaleUpLimitWithScalingRules(1, []timestampedScaleEvent{}, &autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: utilpointer.Int32Ptr(300),
|
||||
SelectPolicy: &policy,
|
||||
Policies: []autoscalingv2.HPAScalingPolicy{
|
||||
{
|
||||
Type: autoscalingv2.PodsScalingPolicy,
|
||||
Value: 2,
|
||||
PeriodSeconds: 60,
|
||||
},
|
||||
{
|
||||
Type: autoscalingv2.PercentScalingPolicy,
|
||||
Value: 50,
|
||||
PeriodSeconds: 60,
|
||||
},
|
||||
},
|
||||
})
|
||||
assert.Equal(t, calculated, int32(2))
|
||||
}
|
||||
|
||||
func TestCalculateScaleDownLimitWithBehaviors(t *testing.T) {
|
||||
policy := autoscalingv2.MinPolicySelect
|
||||
|
||||
calculated := calculateScaleDownLimitWithBehaviors(5, []timestampedScaleEvent{}, &autoscalingv2.HPAScalingRules{
|
||||
StabilizationWindowSeconds: utilpointer.Int32Ptr(300),
|
||||
SelectPolicy: &policy,
|
||||
Policies: []autoscalingv2.HPAScalingPolicy{
|
||||
{
|
||||
Type: autoscalingv2.PodsScalingPolicy,
|
||||
Value: 2,
|
||||
PeriodSeconds: 60,
|
||||
},
|
||||
{
|
||||
Type: autoscalingv2.PercentScalingPolicy,
|
||||
Value: 50,
|
||||
PeriodSeconds: 60,
|
||||
},
|
||||
},
|
||||
})
|
||||
assert.Equal(t, calculated, int32(3))
|
||||
}
|
||||
|
||||
func generateScalingRules(pods, podsPeriod, percent, percentPeriod, stabilizationWindow int32) *autoscalingv2.HPAScalingRules {
|
||||
policy := autoscalingv2.MaxPolicySelect
|
||||
directionBehavior := autoscalingv2.HPAScalingRules{
|
||||
|
||||
Reference in New Issue
Block a user