mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Merge pull request #35272 from yarntime/refactor_reconcileAutoscaler
Automatic merge from submit-queue rescale immediately if the basic constraints are not satisfied refactor reconcileAutoscaler. If the basic constraints are not satisfied, we should rescale the target ref immediately.
This commit is contained in:
@@ -292,9 +292,12 @@ func (a *HorizontalController) reconcileAutoscaler(hpa *autoscaling.HorizontalPo
|
||||
rescaleReason := ""
|
||||
timestamp := time.Now()
|
||||
|
||||
rescale := true
|
||||
|
||||
if scale.Spec.Replicas == 0 {
|
||||
// Autoscaling is disabled for this resource
|
||||
desiredReplicas = 0
|
||||
rescale = false
|
||||
} else if currentReplicas > hpa.Spec.MaxReplicas {
|
||||
rescaleReason = "Current number of replicas above Spec.MaxReplicas"
|
||||
desiredReplicas = hpa.Spec.MaxReplicas
|
||||
@@ -360,9 +363,10 @@ func (a *HorizontalController) reconcileAutoscaler(hpa *autoscaling.HorizontalPo
|
||||
if desiredReplicas > calculateScaleUpLimit(currentReplicas) {
|
||||
desiredReplicas = calculateScaleUpLimit(currentReplicas)
|
||||
}
|
||||
|
||||
rescale = shouldScale(hpa, currentReplicas, desiredReplicas, timestamp)
|
||||
}
|
||||
|
||||
rescale := shouldScale(hpa, currentReplicas, desiredReplicas, timestamp)
|
||||
if rescale {
|
||||
scale.Spec.Replicas = desiredReplicas
|
||||
_, err = a.scaleNamespacer.Scales(hpa.Namespace).Update(hpa.Spec.ScaleTargetRef.Kind, scale)
|
||||
|
||||
Reference in New Issue
Block a user